This module implements an asynchronous lock. When performing asynchronous input and output, the order of reading and writing is very important. In order to ensure the correct order of reading and writing, locks are required for synchronization or queuing.
Asynchronous locks are Netkit's underlying mechanism to provide IO consistency. Netkit provides open APIs independent of "locks".
As with synchronous style locks, you should always operate a lock in window mode and bind a lock to a specific object as much as possible to avoid problems such as deadlock and livelock.
Procs
proc initAsyncLock(): AsyncLock {...}{.raises: [], tags: [].}
- Initializes an AsyncLock. Source Edit
proc acquire(L: var AsyncLock): Future[void] {...}{.raises: [FutureError, Exception], tags: [RootEffect].}
- Tries to acquire a lock. When this future is completed, it indicates that the lock is acquired. Source Edit
proc release(L: var AsyncLock) {...}{.raises: [FutureError, Exception, IndexError], tags: [RootEffect].}
- Releases the lock that has been acquired. Source Edit
proc isLocked(L: AsyncLock): bool {...}{.raises: [], tags: [].}
- Returns true if L is locked. Source Edit