Next: , Previous: , Up: actor-lib: A standard library of sorts   [Contents][Index]

6.5 Joiners

The (goblins actor-lib joiners) module provides a means of combining the results of many promises.

Procedure: all-of promises …

Return a promise which resolves on resolution of all promises.

As an example, suppose there is an actor which waits for a period of time before returning whatever it received:

> (define (^procrastinator bcom delay)
    (lambda (x)
      (sleep delay)

all-of can wait for all procrastinators to finish before writing some output:

> (define a-vat (spawn-vat))
> (define b-vat (spawn-vat))
> (define c-vat (spawn-vat))
> (define p1 (with-vat b-vat (spawn ^procrastinator 1)))
> (define p2 (with-vat c-vat (spawn ^procrastinator 2)))
> (with-vat a-vat
    (on (all-of (<- p1 'foo) (<- p2 'bar))
        (lambda (items)
          (display items)
; (foo bar)
Procedure: all-of* promises

Like all-of, but promises is a list of promises.