mirror of
https://github.com/logos-storage/apatheia.git
synced 2026-01-02 13:03:11 +00:00
31 lines
591 B
Nim
31 lines
591 B
Nim
import std/os
|
|
import std/sequtils
|
|
|
|
import chronos
|
|
import chronos/threadsync
|
|
import chronos/unittest2/asynctests
|
|
import taskpools
|
|
|
|
import apatheia/queues
|
|
|
|
proc worker(data: seq[char], queue: SignalQueue[int]) =
|
|
os.sleep(50)
|
|
echo "worker: ", data
|
|
discard queue.send(data.len())
|
|
|
|
suite "async tests":
|
|
|
|
var tp = Taskpool.new(num_threads = 2) # Default to the number of hardware threads.
|
|
var queue = newSignalQueue[int]()
|
|
|
|
asyncTest "test":
|
|
|
|
## init
|
|
var data = "hello world!".toSeq
|
|
tp.spawn worker(data, queue)
|
|
|
|
let res = await wait(queue)
|
|
check res.get() == 12
|
|
|
|
|