syndicate-nim/tests/test_timers.nim

23 lines
676 B
Nim
Raw Normal View History

2023-07-13 14:07:04 +00:00
# SPDX-FileCopyrightText: ☭ Emery Hemingway
# SPDX-License-Identifier: Unlicense
import std/times
import syndicate, syndicate/actors/timers
2023-07-13 14:07:04 +00:00
2024-04-02 15:34:33 +00:00
runActor("timer-test") do (turn: var Turn):
2024-03-01 14:10:40 +00:00
let timers = newDataspace(turn)
2024-03-14 13:14:51 +00:00
spawnTimerActor(turn, timers)
2023-07-13 14:07:04 +00:00
2024-03-01 14:10:40 +00:00
onPublish(turn, timers, ?LaterThan(seconds: 1356100000)):
echo "now in 13th bʼakʼtun"
2024-03-08 15:40:07 +00:00
after(turn, timers, initDuration(seconds = 3)) do (turn: var Turn):
2024-03-01 14:10:40 +00:00
echo "third timer expired"
stopActor(turn)
2024-03-08 15:40:07 +00:00
after(turn, timers, initDuration(seconds = 1)) do (turn: var Turn):
2024-03-01 14:10:40 +00:00
echo "first timer expired"
2024-03-08 15:40:07 +00:00
after(turn, timers, initDuration(seconds = 2)) do (turn: var Turn):
2024-03-01 14:10:40 +00:00
echo "second timer expired"