Next: , Previous: , Up: Persistence   [Contents][Index]


8.4 Persistent Vats

When a vat is spawned, it can be spawned as a persistent vat with a given persistence environment and set of roots. The vat also has a storage provider associated with it. Vats can be persisted either on each churn (when the vat reaches quiescence), or manually. If a vat is configured to persist on churns, just the objects which have changed (using become) will be persisted.

Procedure: spawn-persistent-vat persistent-env spawn-roots-thunk store [#:persist-on] [#:vat-constructor] [#:name] [#:log?]

[#:log-capacity]

Create and return a reference to a new vat configured with persistence.

  • persistence-env: The persistence environment containing all objects within the persistence graph (See Persistence Environments)
  • spawn-roots-thunk: A thunk which is invoked if no persisted state of the vat exists. The lambda should spawn and return the roots of the object graph to be persisted.
  • store: The store that persistence data will be read and written to See Persistence stores.
  • persist-on: If 'churn will persist on churns, otherwise in a manual persistence mode (default: 'churn).
  • vat-constructor: The constructor used to create the vat, defaults to spawn-fibrous-vat.

    name: Name of the vat. Note that this is not the name it is bound to in the current namespace.

  • log?: If #t, log vat events; otherwise, do not.
  • log-capacity: Number of events to be retained in the log. Defaults to 256.
(define-actor (^counter bcom value)
  (lambda ()
    (bcom (^counter bcom (+ 1 value)) value)))

(define persistence-env
  (make-persistence-env
   `((((counter) ^counter) ,^counter))))

(define-values (vat my-counter)
  (spawn-persistent-vat
   persistence-env
   (lambda ()
     (spawn ^counter 0))
   (make-memory-store)))

Next: Persistence Environments, Previous: Operations on actormaps, Up: Persistence   [Contents][Index]