Next: Actormap objects, Up: Actormaps [Contents][Index]
An actormap is fundamentally a place in memory holding references to objects so that they may be manipulated. There are two types of actormaps: whactormaps, which use weak-key hash tables as the backing data structure so objects may be garbage collected automatically, and which serve as the root of a generational transaction history of actormap actions; and transactormaps, which are backed by standard hash tables and constitute every other generation of a transaction history. Aside from their backing data structures and resulting use cases, all actormaps are very similar; transactormaps simply also hold a reference to a parent, which is either another transactormap or the root whactormap.
The best way to understand actormaps is by using them. First, create one:
(define am (make-actormap))
Actormaps need actors, so add a simple cell
:
(define lunchbox (actormap-spawn! am ^cell))
Actors can then be invoked, such as by actormap-poke!
:
> (actormap-poke! am lunchbox 'peanut-butter-and-jelly) > (actormap-peek am lunchbox) ; => 'peanut-butter-and-jelly
For some situations, actormap-poke!
and actormap-peek
can be interchanged, such as in this version of the above example:
> (actormap-poke! am lunchbox 'bbq-tofu) > (actormap-poke! am lunchbox) ; => 'bbq-tofu
For other situations, they cannot:
> (actormap-peek am lunchbox 'chickpea-salad) > (actormap-peek am lunchbox) ; => 'bbq-tofu
This is due to the transactional nature of actormaps.
In these examples, you can see that actormap-poke!
returns a
value and commits changes to the transaction history, while
actormap-peek
returns a value and throws away changes. Both
of these procedures are conveniences over the more powerful and more
cumbersome actormap-turn
family of procedures.
The next sections will cover these and related procedures in greater detail.
Next: Actormap objects, Up: Actormaps [Contents][Index]