| ||Simulation of other Paradigms and Continuations - slide 38 : 43|
A simpel producer and consumer
We show two different variants of a simple producer consumer pattern
Producer Consumer - pure functional programming in Scheme.
- Essential steps:
- Start the producer
- The producer prepares the first iteration, and returns its first continuation via exit
- The consumer starts - it receives the first producer continuation
- Now the resume-resume interaction takes place
- At the end the producer sends a stop value to the consumer
- In the consumer, the stop value ends consumation
Alternative Producer Consumer - the other coroutine is maintained in mutable state.
It is tricky to start up the two continuations
Explicit passing of continuations between the coroutines is clumsy - Keeping the continuation 'of the other part' in mutable state is an alternative