2023-07-13 14:07:04 +00:00
|
|
|
|
# SPDX-FileCopyrightText: ☭ Emery Hemingway
|
|
|
|
|
# SPDX-License-Identifier: Unlicense
|
|
|
|
|
|
2023-07-23 07:29:45 +00:00
|
|
|
|
import std/times
|
2024-04-03 09:59:47 +00:00
|
|
|
|
import syndicate, syndicate/drivers/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-04-03 09:59:47 +00:00
|
|
|
|
spawnTimerDriver(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"
|