ide / await-lock

Mutex locks for async functions
MIT License
89 stars 12 forks source link

implement timeout and maxOccupationTime #18

Closed bmrpatel closed 2 years ago

bmrpatel commented 3 years ago

similar to async-lock library, please implement timeout and maxOccupationTime

timeout -> timed out error will be returned here if lock not acquired in given time maxOccupationTime -> occupation time exceeded error will be returned here if job not completed in given time

ide commented 3 years ago

I would prefer features that can be easily implemented outside of this library to do so. The occupation time can be easily implemented with Promise.race, setTimeout, and lock.release.

A timeout for acquiring the lock might make sense to implement internally.

ide commented 2 years ago

v2.2.0 and up supports an optional timeout field passed into acquireAsync. Occupation time can be implemented in user space and won't be added to this library.