logoalt Hacker News

sedatkyesterday at 9:08 PM3 repliesview on HN

Blocking async code is not async. In order for something to execute "out of order", you must have an escape mechanism from that task, and that mechanism essentially dictates a form of concurrency. Async must be concurrent, otherwise it stops being async. It becomes synchronous.


Replies

nemothekidyesterday at 9:58 PM

Consider:

    readA.await
    readB.await
From the perspective of the application programmer, readA "block" readB. They aren't concurrent.

    join(readA, readB).await
In this example, the two operations are interleaved and the reads happen concurrently. The author makes this distinction and I think it's a useful one, that I imagine most people are familiar with even if there is no name for it.
show 1 reply
vitaminCPPyesterday at 9:41 PM

This is exactly what the article is trying to debunk.

didibusyesterday at 9:46 PM

If you need to do A and then B in that order, but you're doing B and then A. It doesn't matter if you're doing B and then A in a single thread, the operations are out of sync.

So I guess you could define this scenario as asynchronous.

show 1 reply