@@ -15,18 +15,18 @@ import chronos, chronicles
1515logScope:
1616 topics = " libp2p semaphore"
1717
18- type AsyncSemaphore * = ref object of RootObj
18+ type AsyncSemaphore1 * = ref object of RootObj
1919 size* : int
2020 count: int # count of available slots
2121 queue: seq [Future [void ]]
2222
23- proc newAsyncSemaphore * (size: int ): AsyncSemaphore =
24- AsyncSemaphore (size: size, count: size)
23+ proc newAsyncSemaphore1 * (size: int ): AsyncSemaphore1 =
24+ AsyncSemaphore1 (size: size, count: size)
2525
26- proc `count` * (s: AsyncSemaphore ): int =
26+ proc `count` * (s: AsyncSemaphore1 ): int =
2727 s.count
2828
29- proc tryAcquire * (s: AsyncSemaphore ): bool =
29+ proc tryAcquire * (s: AsyncSemaphore1 ): bool =
3030 # # Attempts to acquire a resource, if successful
3131 # # returns true, otherwise false
3232 # #
@@ -37,15 +37,15 @@ proc tryAcquire*(s: AsyncSemaphore): bool =
3737 return true
3838
3939proc acquire * (
40- s: AsyncSemaphore
40+ s: AsyncSemaphore1
4141): Future [void ] {.async : (raises: [CancelledError ], raw: true ).} =
4242 # # Acquire a resource and decrement the resource
4343 # # counter. If no more resources are available,
4444 # # the returned future will not complete until
4545 # # the resource count goes above 0.
4646 # #
4747
48- let fut = newFuture [void ](" AsyncSemaphore .acquire" )
48+ let fut = newFuture [void ](" AsyncSemaphore1 .acquire" )
4949 if s.tryAcquire ():
5050 fut.complete ()
5151 return fut
@@ -62,14 +62,14 @@ proc acquire*(
6262 trace " Queued slot" , available = s.count, queue = s.queue.len
6363 return fut
6464
65- proc forceAcquire * (s: AsyncSemaphore ) =
65+ proc forceAcquire * (s: AsyncSemaphore1 ) =
6666 # # ForceAcquire will always succeed,
6767 # # creating a temporary slot if required.
6868 # # This temporary slot will stay usable until
6969 # # there is less `acquire`s than `release`s
7070 s.count.dec
7171
72- proc release * (s: AsyncSemaphore ) =
72+ proc release * (s: AsyncSemaphore1 ) =
7373 # # Release a resource from the semaphore,
7474 # # by picking the first future from the queue
7575 # # and completing it and incrementing the
0 commit comments