Next: , Previous: Rendezvous concepts, Up: Concurrent ML


5.4.3 Rendezvous combinators

The rendezvous structure exports several basic rendezvous combinators.

— Constant: never-rv –> rendezvous

A rendezvous that is never enabled. If synchronized, this will block the synchronizing thread indefinitely.

— procedure: always-rv value –> rendezvous

Returns a rendezvous that is always enabled with the given value. This rendezvous will never block the synchronizing thread.

— procedure: guard rv-generator –> rendezvous
— procedure: with-nack rv-generator –> rendezvous

Guard returns a delayed rendezvous, generated by the given procedure rv-generator, which is passed zero arguments whenever the resultant rendezvous is synchronized. With-nack returns a delayed rendezvous for which a negative acknowledgement rendezvous is constructed. If the resultant rendezvous is synchronized as a part of a composite rendezvous, the procedure rv-generator is passed a nack for the synchronization, and it returns the rendezvous to actually synchronize. If the delayed rendezvous was synchronized as part of a composite group of rendezvous, and another rendezvous among that group is enabled and chosen first, the nack is enabled.

— procedure: choose rendezvous ... –> composite-rendezvous

Returns a rendezvous that, when synchronized, synchronizes all of the given components, and chooses only the first one to become enabled, or the highest priority one if there are any that are already enabled. If any of the rendezvous that were not chosen when the composite became enabled were delayed rendezvous with nacks, their nacks are enabled.

— procedure: wrap rendezvous procedure –> rendezvous

Returns a rendezvous equivalent to rendezvous but wrapped with procedure, so that, when the resultant rendezvous is synchronized, rendezvous is transitively synchronized, and when rendezvous is enabled, the resultant rendezvous is also enabled, with the value that procedure returns when passed the value produced by rendezvous.

          (sync (wrap (always-rv 4)
                      (lambda (x) (* x x))))      --> 16
— procedure: sync rendezvous –> value (may block)
— procedure: select rendezvous ... –> value (may block)

Sync and select synchronize rendezvous. Sync synchronizes a single one; select synchronizes any from the given set of them. Select is equivalent to (sync (apply choose rendezvous ...)), but it may be implemented more efficiently.

5.4.3.1 Timing rendezvous

The rendezvous-time structure exports two constructors for rendezvous that become enabled only at a specific time or after a delay in time.

— procedure: at-real-time-rv milliseconds –> rendezvous
— procedure: after-time-rv milliseconds –> rendezvous

At-real-time-rv returns a rendezvous that becomes enabled at the time milliseconds relative to the start of the Scheme program. After-time-rv returns a rendezvous that becomes enabled at least milliseconds after synchronization (not construction).