Next: , Previous: , Up: Api   [Contents][Index]


5.6 Block

Class: <blocking-continuation>

We’re going to capture these blocking continuations into a class.

Variable: blocking-continuations

[[call-blockable]] will handle any aborts to the [[’block]] prompt. If the thunk aborts, it adds an instance of the class [[<blocking-continuation>]] to a list of such instances.

Scheme Procedure: block-yield
Scheme Procedure: call-blockable thunk
Scheme Procedure: block-tick

To possibly resume these continuations, we’re going to call [[block-tick]]. Additionally, continuations come in two flavors: serial and non-serial. The constraints on resuming are different. A non-serial block can be resumed whenever the [[continue-when?]] thunk return true. A serial block, however, will only be resumed after every other serial block that has a greater number, meaning more recent, has been resumed.

Scheme Procedure: blocking?
Scheme Procedure: maybe-continue (obj <blocking-continuation>)
Scheme Procedure: block-until condition-thunk #:optional (serial? #f)

In addition to simply yielding we can block until a particular condition is met.

Scheme Procedure: block-while condition-thunk #:optional (serial? #f)

And if we have [[block-until]], it’s easy to write [[block-while]].

Scheme Procedure: block-kill (obj <blocking-continuation>)

Sometimes we may just want to kill a blocking continuation. One could just forget the reference and let it be garbage collected. Here, we’re going to throw an exception such that whatever the continuation was doing can potentially be cleaned up.