libp2p/utils/semaphore

    Dark Mode
Search:
Group by:
  Source   Edit

Types

AsyncSemaphore = ref object of RootObj
  size*: int
  count: int
  queue: seq[Future[void]]
  Source   Edit

Procs

proc acquire(s: AsyncSemaphore): Future[void] {....raises: [], tags: [].}
Acquire a resource and decrement the resource counter. If no more resources are available, the returned future will not complete until the resource count goes above 0.   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