# SPDX-FileCopyrightText: ☭ Emery Hemingway # SPDX-License-Identifier: Unlicense import std/times import pkg/cps import syndicate # import syndicate/actors/timers proc now: float64 = getTime().toUnixFloat() proc main() {.syndicate.} = discard activeTurn() let ds = newDataspace() let h = publish(ds, "hello world!".toPreserves) message(ds, "hello world!".toPreserves) retract(h) sync(ds) echo "stopping actor" stopActor() echo "actor stopped but still executing?" #onMessage(ds, grab()) do (v: Value): # stderr.writeLine "observed message ", v #[ block: spawnTimers(ds) onPublish(ds, grab(LaterThan(seconds: now()+1.0))) do: stderr.writeLine "slept one second once" onPublish(ds, grab(LaterThan(seconds: now()+1.0))) do: stderr.writeLine "slept one second twice" onPublish(ds, grab(LaterThan(seconds: now()+1.0))) do: stderr.writeLine "slept one second thrice" quit() ]# bootActor("main", whelp main())