Let me rant about a bigger point: What are coroutines conceptually? Well, it&#x27;s a &quot;thing&quot; that we use in order to express sequential code (I&#x27;m sure there is more abstract definition).<p>What is a difference between Erlang Proc, Golang Goroutine, Operating System Thread, and this kind of Duff&#x27;s device - not much if you think about it. It&#x27;s all about sequential code with
a bit of context (variables) attached - the closure.<p>The only difference between a thread and asynchronous programming is how you deal with the context - is it explicit or implicit?<p>In this Duff&#x27;s device, the context is passed explicitly. It&#x27;s an (arguably nice) syntactic sugar over a trivial state machine.<p>The main point here is - how large is the context? If that&#x27;s a few variables, sure you can pack them on a struct, or just async programming. If the context is somewhat non-trivial, having it implicit makes sense. If the context is really large you probably _must_ use OS &#x2F; programming language help.<p>The problem - the larger the context, the costlier the context switch. It would be nice to have some kind of magic that would be able to chose the optimal coroutines hardware implementation based on the size of context.