running 1000+ outer loops

This commit is contained in:
Jaremy Creechley 2023-09-27 14:01:21 -07:00
parent fbc00613c4
commit efd2e1d19d
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 13 additions and 13 deletions

View File

@ -68,7 +68,7 @@ proc setDone[T](ctx: TaskCtx[T]) =
ctx[].running = false ctx[].running = false
proc acquireSignal(): ?!ThreadSignalPtr = proc acquireSignal(): ?!ThreadSignalPtr =
echo "signal:OPEN!" # echo "signal:OPEN!"
let signal = ThreadSignalPtr.new() let signal = ThreadSignalPtr.new()
if signal.isErr(): if signal.isErr():
failure (ref CatchableError)(msg: "failed to aquire ThreadSignalPtr: " & signal.error()) failure (ref CatchableError)(msg: "failed to aquire ThreadSignalPtr: " & signal.error())
@ -126,7 +126,7 @@ template dispatchTask[BT](self: ThreadDatastore[BT],
ctx.setCancelled() ctx.setCancelled()
raise exc raise exc
finally: finally:
echo "signal:CLOSE!" # echo "signal:CLOSE!"
discard ctx[].signal.close() discard ctx[].signal.close()
self.semaphore.release() self.semaphore.release()
@ -286,13 +286,13 @@ method query*[BT](self: ThreadDatastore[BT],
without signal =? acquireSignal(), err: without signal =? acquireSignal(), err:
return failure err return failure err
let ctx = newTaskCtx(QResult, signal=signal) let ctx = newTaskCtx(QResult, signal=signal)
echo "nextSignal:OPEN!" # echo "nextSignal:OPEN!"
ctx[].nextSignal.init() ctx[].nextSignal.init()
proc iterDispose() = proc iterDispose() =
echo "signal:CLOSE!" # echo "signal:CLOSE!"
discard signal.close() discard signal.close()
echo "nextSignal:CLOSE!" # echo "nextSignal:CLOSE!"
ctx[].nextSignal.close() ctx[].nextSignal.close()
self.semaphore.release() self.semaphore.release()

View File

@ -33,9 +33,9 @@ for i in 1..N:
suite "Test Basic ThreadDatastore with SQLite": suite "Test Basic ThreadDatastore with SQLite":
var var
sqlStore = newSQLiteBackend[KeyId, DataBuffer](Memory).tryGet() sqlStore: SQLiteBackend[KeyId, DataBuffer]
taskPool = Taskpool.new(NumThreads) taskPool: Taskpool
ds = ThreadDatastore.new(sqlStore, tp = taskPool).tryGet() ds: ThreadDatastore[SQLiteBackend[KeyId, DataBuffer]]
key = Key.init("/a/b").tryGet() key = Key.init("/a/b").tryGet()
bytes = "some bytes".toBytes bytes = "some bytes".toBytes
otherBytes = "some other bytes".toBytes otherBytes = "some other bytes".toBytes
@ -52,17 +52,17 @@ for i in 1..N:
(await ds.close()).tryGet() (await ds.close()).tryGet()
taskPool.shutdown() taskPool.shutdown()
# for i in 1..M: for i in 1..M:
# basicStoreTests(ds, key, bytes, otherBytes) basicStoreTests(ds, key, bytes, otherBytes)
GC_fullCollect() GC_fullCollect()
for i in 1..N: for i in 1..N:
suite "Test Query ThreadDatastore with SQLite": suite "Test Query ThreadDatastore with SQLite":
var var
sqlStore = newSQLiteBackend[KeyId, DataBuffer](Memory).tryGet() sqlStore: SQLiteBackend[KeyId, DataBuffer]
taskPool = Taskpool.new(NumThreads) taskPool: Taskpool
ds = ThreadDatastore.new(sqlStore, tp = taskPool).tryGet() ds: ThreadDatastore[SQLiteBackend[KeyId, DataBuffer]]
setup: setup:
sqlStore = newSQLiteBackend[KeyId, DataBuffer](Memory).tryGet() sqlStore = newSQLiteBackend[KeyId, DataBuffer](Memory).tryGet()