add nextSignal using mutex

This commit is contained in:
Jaremy Creechley 2023-09-27 13:35:14 -07:00
parent 3cc21b3a59
commit 1da59ba730
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 10 additions and 3 deletions

View File

@ -131,6 +131,7 @@ template dispatchTask[BT](self: ThreadDatastore[BT],
ctx.setCancelled()
raise exc
finally:
echo "signal:CLOSE!"
discard ctx[].signal.close()
self.semaphore.release()
@ -333,6 +334,7 @@ method query*[BT](self: ThreadDatastore[BT],
except CancelledError as exc:
trace "Cancelling thread future!", exc = exc.msg
ctx.setCancelled()
echo "signal:CLOSE!"
discard ctx[].signal.close()
echo "nextSignal:CLOSE!"
ctx[].nextSignal.close()
@ -343,6 +345,7 @@ method query*[BT](self: ThreadDatastore[BT],
return success iter
except CancelledError as exc:
trace "Cancelling thread future!", exc = exc.msg
echo "signal:CLOSE!"
discard signal.close()
echo "nextSignal:CLOSE!"
ctx[].nextSignal.close()

View File

@ -24,8 +24,10 @@ import ./querycommontests
const
NumThreads = 20 # IO threads aren't attached to CPU count
ThreadTestLoops {.intdefine.} = 1000
ThreadTestLoops {.intdefine.} = 1
N = ThreadTestLoops
ThreadTestInnerLoops {.intdefine.} = 1
M = ThreadTestInnerLoops
for i in 1..N:
suite "Test Basic ThreadDatastore with SQLite":
@ -50,7 +52,8 @@ for i in 1..N:
(await ds.close()).tryGet()
taskPool.shutdown()
basicStoreTests(ds, key, bytes, otherBytes)
for i in 1..M:
basicStoreTests(ds, key, bytes, otherBytes)
GC_fullCollect()
for i in 1..N:
@ -72,7 +75,8 @@ for i in 1..N:
(await ds.close()).tryGet()
taskPool.shutdown()
queryTests(ds, true)
for i in 1..M:
queryTests(ds, true)
GC_fullCollect()
# suite "Test Basic ThreadDatastore with fsds":