-
-
Notifications
You must be signed in to change notification settings - Fork 5
async
Pannous edited this page Dec 28, 2022
·
4 revisions
The async await pattern is cancer: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/
Starting an async process belongs on the caller site, note on the callee site!
Correct way of handling threads: See zig and go, hell, even Java
go figure() right
goable figure (){}; await figure() wrong
In the angle language, a concurrent call is created by the go keyword, whether in a thread or not should be of no concern when writing code! It creates a typed task object wich can be stopped etc and can be assigned to its value type through auto casting:
job=go download url
html=job!
Here the ! makes sure the task is started (if it was paused) and acts as await.
The go keyword implicitly creates signal handlers which can be listened to via once etc:
once the download finishes: print "done!"
once the download pauses: print "holup!"
on download.stop : print "cancelled"
See evaluation