Async handler — the worker handles other work while suspended

while H1 gives up the thread on await, the worker runs H2 first, and H1 resumes when the response arrives

Async handler — the worker handles other work while suspended while H1 gives up the thread on await, the worker runs H2 first, and H1 resumes when the response arrives run HandleAsync() await Request(...) → suspend, release thread worker moves to the next work — run HandleAsync() return (done) response arrives → resume return (done) worker thread · Sequence participant worker thread Handler A · async · Sequence participant Handler A async Play channel · Sequence participant Play channel Handler B · async · Sequence participant Handler B async

Non-blocking interleaving

  • • When H1 suspends at the await Request point, only that flow of execution pauses and the thread returns to the pool — it holds no thread.
  • • The worker immediately picks up the next work (H2) and runs it, and H2 finishes before H1's response arrives.

resume

  • • When the Play channel's response arrives, H1 resumes on the spot and returns.
  • • So a handful of workers handle huge numbers of concurrent requests with code that reads top to bottom, no callbacks. Blocking with .Result keeps the thread occupied, so it's forbidden inside a handler.