metarhia / metasync

Asynchronous Programming Library for JavaScript & Node.js
https://metarhia.com
MIT License
206 stars 35 forks source link

Implement TimedMutex #414

Open tshemsedinov opened 5 years ago

tshemsedinov commented 5 years ago

TimedMutex allow us to lock shared resource for an interval less then timeout

class TimedMutex {
  status: SM_UNLOCKED | SM_LOCKED,
  constructor(timeout),
  timeout: <number>,
  async enter(callback), // if no callback passed Promise will be returned
  leave()
}