Next: Concurrent ML to Scheme correspondence, Previous: Rendezvous communication channels, Up: Concurrent ML
Placeholders1 are single-assignment cells on which readers block until they are assigned.
Note: These placeholders are disjoint from and incompatible
with the placeholder mechanism provided in the placeholders
structure, and attempts to apply operations on one to values of the
other are errors.
Make-placeholder
creates and returns a new, empty placeholder. Id is used only for debugging purposes; it is included in the printed representation of the placeholder.Placeholder?
is the disjoint type predicate for placeholders.
Placeholder-value-rv
returns a rendezvous that, when synchronized, becomes enabled when placeholder has a value, with that value.Placeholder-value
has the effect of immediately synchronizing such a rendezvous, and it returns the value directly, but possibly after blocking.
Sets placeholder's value to be value, and enables all rendezvous for placeholder's value with that value. It is an error if placeholder has already been assigned.
Jars2 are multiple-assignment cells on which readers block. Reading from a full jar has the effect of emptying it, enabling the possibility of subsequent assignment, unlike placeholders; and jars may be assigned multiple times, but, like placeholders, only jars that are empty may be assigned.
Make-jar
creates and returns a new, empty jar. Id is used only for debugging purposes; it is included in the printed representation of the jar.Jar?
is the disjoint type predicate for jars.
Jar-take-rv
returns a rendezvous that, when synchronized, becomes enabled when jar has a value, which is what value the rendezvous becomes enabled with; when that rendezvous is enabled, it also removes the value from jar, putting the jar into an empty state.Jar-take
has the effect of synchronizing such a rendezvous, may block because of that, and returns the value of the jar directly, not a rendezvous.
Jar-put!
puts value into the empty jar jar. If any taker rendezvous are waiting, the first is enabled with the value, and the jar is returned to its empty state; otherwise, the jar is put in the full state.Jar-put!
is an error if applied to a full jar.