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


6.9 Opportunistic

The (goblins actor-lib opportunistic) module provides procedures to choose synchronous invocation if possible and fallback to asynchronous invocation only if necessary.

Procedure: select-$/<- to-refr

If the actor to-refr is a near object, return $; otherwise, return <-.

Procedure: run-$/<- to-refr args …

Invoke the actor to-refr with the arguments args using $ if it is a near object and otherwise using <-.

> (define a-vat (spawn-vat))
> (define b-vat (spawn-vat))
> (define a-chest (with-vat a-vat
                    (spawn ^cell 'sword)))
> (with-vat a-vat
    (run-$/<- a-chest))
=> 'sword
> (with-vat b-vat
    (run-$/<- a-chest))
=> #<local-promise>