mirror of
https://github.com/logos-storage/apatheia.git
synced 2026-01-05 06:23:07 +00:00
initial setup
This commit is contained in:
parent
3995c73974
commit
b53cced09e
@ -12,8 +12,8 @@ type
|
||||
DataObj = ref object
|
||||
data: seq[char]
|
||||
|
||||
proc worker(data: seq[char], queue: SignalQueue[int]) =
|
||||
os.sleep(5000)
|
||||
proc worker(data: OpenArrayHolder[char], queue: SignalQueue[int]) =
|
||||
os.sleep(1_000)
|
||||
echo "worker: ", data
|
||||
discard queue.send(data.len())
|
||||
|
||||
@ -22,14 +22,15 @@ proc finalizer(obj: DataObj) =
|
||||
|
||||
proc runTest(tp: TaskPool, queue: SignalQueue[int]) {.async.} =
|
||||
## init
|
||||
var data = "hello world!".toSeq
|
||||
var obj: DataObj
|
||||
new(obj, finalizer)
|
||||
obj.data = "hello world!".toSeq
|
||||
|
||||
echo "spawn worker"
|
||||
tp.spawn worker(data, queue)
|
||||
tp.spawn worker(obj.data, queue)
|
||||
|
||||
let res = await wait(queue)
|
||||
let res =
|
||||
await wait(queue).wait(100.milliseconds)
|
||||
check res.get() == 12
|
||||
|
||||
suite "async tests":
|
||||
@ -39,8 +40,13 @@ suite "async tests":
|
||||
|
||||
asyncTest "test":
|
||||
|
||||
await runTest(tp, queue)
|
||||
GC_fullCollect()
|
||||
try:
|
||||
await runTest(tp, queue)
|
||||
except AsyncTimeoutError as err:
|
||||
echo "Run GC"
|
||||
GC_fullCollect()
|
||||
os.sleep(2_000)
|
||||
echo "Done"
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user