-
-
Notifications
You must be signed in to change notification settings - Fork 4
thread
Pannous edited this page Dec 28, 2022
·
5 revisions
async threading follows the go/zig path to be invoked on the caller side.
On the callee side, functions are agnostic whether they are called in a synchronous or asynchronous way.
This way function coloring and the huge syntactic and semantic async/await overhead mess is avoided:
go { sleep 1s and print "second"; done = true }
print "first"
last = after done return "third"
cancel last
// print last // warning: last is optional and asynchronous
print await last or "no third"
The after
keyword creates an (aspect oriented) implicit signal listener on the variable done
Concurrent or asynchronous tasks can be paused, stopped, etc
Avoiding Function coloring: https://news.ycombinator.com/item?id=28657358