From: jim Date: Wed, 29 Apr 2015 15:24:37 +0000 (-0400) Subject: add header X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=commitdiff_plain;h=4cd46c1664472437f701377fe1851db42ed063cf add header --- diff --git a/topics/_coroutines_and_aborts.mdwn b/topics/_coroutines_and_aborts.mdwn index d7c8b03e..389e7d5e 100644 --- a/topics/_coroutines_and_aborts.mdwn +++ b/topics/_coroutines_and_aborts.mdwn @@ -1,5 +1,7 @@ [[!toc]] +## Coroutines ## + Recall [[the recent homework assignment|/exercises/assignment12]] where you solved the same-fringe problem with a `make_fringe_enumerator` function, or in the Scheme version using streams instead of zippers, with a `lazy-flatten` function. The technique illustrated in those solutions is a powerful and important one. It's an example of what's sometimes called **cooperative threading**. A "thread" is a subprogram that the main computation spawns off. Threads are called "cooperative" when the code of the main computation and the thread fixes when control passes back and forth between them. (When the code doesn't control this---for example, it's determined by the operating system or the hardware in ways that the programmer can't predict---that's called "preemptive threading.") Cooperative threads are also sometimes called *coroutines* or *generators*.