Event-Driven Flows
akrzemi1.wordpress.com¡6d¡
Flag this post

This post is in response to two claims about coroutines:

  1. Their reference function parameters may become dangling too easily.
  2. They are indistinguishable from regular functions from the declaration alone.

But rather than talking about coroutines, we will look at event-driven control flows in general. Modelling them is one of the primary motivations (alongside “generators”) for having coroutines. By understanding the need we will be better equipped to understand the tool.

Event-driven flows

A canonical example of an event-driven flow is the handling of signals in C. Signals will be risen at unpredictable points in time, so rather than actively checking for them, we define a callback and associate it with the indicated signal:

signal(SIGINT, on_interrupt);

A…

Similar Posts

Loading similar posts...