logoalt Hacker News

jpc0yesterday at 7:13 PM0 repliesview on HN

I liked where you started.

Any ASYNC operation, whether using coroutines or event based actors or whatever else should be modelled as a network call.

You need a handle that will contain information about the async call and will own the work it performs. You can have an API that explicitly says “I don’t care what happens to this thing just that it happens” and will crash on failure. Or you can handle its errors if there are any and importantly decide how to handle those errors.

Oh and failing to allocate/create that handle should be a breach of invariants and immediately crash.

That way you have all the control and flexibility and Async error handling becomes trivial, you can use whatever async pattern you want to manage async operations at that point as well.

And you also know you have fundamentally done something expensive in latency for the benefit of performance or access to information, because if it was cheap you would have just done it on the thread you are already using.