Types
AsyncSemaphore = ref object of RootObj size*: int count: int queue: seq[Future[void]]
- Source Edit
Procs
proc acquire(s: AsyncSemaphore): InternalRaisesFuture[void, (CancelledError,)] {. stackTrace: false, ...raises: [], gcsafe, raises: [], raises: [], tags: [].}
- Source Edit
proc count(s: AsyncSemaphore): int {....raises: [], tags: [].}
- Source Edit
proc forceAcquire(s: AsyncSemaphore) {....raises: [], tags: [].}
- ForceAcquire will always succeed, creating a temporary slot if required. This temporary slot will stay usable until there is less acquires than releases Source Edit
proc newAsyncSemaphore(size: int): AsyncSemaphore {....raises: [], tags: [].}
- Source Edit
proc release(s: AsyncSemaphore) {....raises: [], tags: [].}
- Release a resource from the semaphore, by picking the first future from the queue and completing it and incrementing the internal resource count Source Edit
proc tryAcquire(s: AsyncSemaphore): bool {....raises: [], tags: [].}
- Attempts to acquire a resource, if successful returns true, otherwise false Source Edit