libp2p/utils/semaphore

Search:
Group by:
Source   Edit  

Types

AsyncSemaphore = ref object of RootObj
  size*: int
  
Source   Edit  

Procs

proc acquire(s: AsyncSemaphore): Future[void] {....raises: [], tags: [RootEffect],
    forbids: [].}
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: [], forbids: [].}
Source   Edit  
proc forceAcquire(s: AsyncSemaphore) {....raises: [], tags: [], forbids: [].}
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: [],
    forbids: [].}
Source   Edit  
proc release(s: AsyncSemaphore) {....raises: [], tags: [RootEffect], forbids: [].}
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: [], forbids: [].}
Attempts to acquire a resource, if successful returns true, otherwise false Source   Edit