remove asyncsemaphore

This commit is contained in:
Dmitriy Ryajov 2023-09-14 18:05:32 -06:00
parent 3500913642
commit 221e93f3a2
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4

View File

@ -22,7 +22,6 @@ import ../query
import ../datastore
import ./semaphore
import ./asyncsemaphore
import ./databuffer
type
@ -38,8 +37,7 @@ type
ThreadDatastore* = ref object of Datastore
tp: Taskpool
ds: Datastore
# semaphore: AsyncSemaphore
semaphore: Semaphore
semaphore: Semaphore # semaphore is used for backpressure to avoid exhausting file descriptors
tasks: seq[Future[void]]
template dispatchTask(
@ -51,7 +49,6 @@ template dispatchTask(
fut = wait(ctx.signal)
try:
# await self.semaphore.acquire()
self.tasks.add(fut)
runTask()
await fut
@ -68,8 +65,6 @@ template dispatchTask(
idx != -1):
self.tasks.del(idx)
# self.semaphore.release()
proc hasTask(
ctx: ptr TaskCtx,
key: ptr Key) =
@ -336,5 +331,4 @@ func new*(
success ThreadDatastore(
tp: tp,
ds: ds,
# semaphore: AsyncSemaphore.new(tp.numThreads - 1)) # one thread is needed for the task dispatcher
semaphore: Semaphore.init((tp.numThreads - 1).uint)) # one thread is needed for the task dispatcher
semaphore: Semaphore.init((tp.numThreads - 1).uint))