Previous: , Up: Vats   [Contents][Index]


5.2.3 Using vats

Regardless of whether a vat is standard or custom, there are several procedures supporting their use.

Procedure: vat? obj

Return #t if obj is a vat, else #f.

Procedure: vat-name vat

Return the name of vat.

Procedure: vat-running? vat

Return #t if vat is running, else #f.

Procedure: vat-halt! vat

Stop processing turns for vat.

Procedure: vat-start! vat

Start processing turns for vat.

Procedure: call-with-vat vat thunk

Run thunk in the context of vat and return the resulting values.

(define a-vat (spawn-vat))
(call-with-vat a-vat
  (lambda ()
    (define an-object (spawn ^some-object))
    ($ an-object 'a-message an-arg)))
Syntax: with-vat vat body …

Execute body in the context of vat and return the result. This is syntax for call-with-vat so the user does not have to write a separate lambda expression.

Syntax: define-vat-run vat-run-id [vat (spawn-vat)]

This procedure is deprecated.

Return a procedure bound to vat-run-id accepting a body to be evaluated in the context of vat.

(define-vat-run run-in-vat)
(run-in-vat
  (define a-near-object (spawn ^some-object))
  (<- a-far-object 'some-message an-arg)
  ($ a-near-object 'some-message))