next up previous contents
Next: Actor Creation Up: Writing Concurrent Programs Previous: Writing Concurrent Programs


Actor State Modification

SALSA is a dialect of Java, and it is intended to reuse as many features of Java as possible. SALSA actors can contain internal state in the form of Java objects or primitive types. However, it is important that this internal state must be completely encapsulated, that is, not shared with other actors. It is also important that the internal state be serializable [*]

The following piece of code illustrates how the internal state is modified, as follows:
 
behavior Cell {
  Object contents;

Cell(Object initialContents){ contents = initialContents; }

Object get(){ return contents; }

void set(Object newContents){ // update the variable 'contents' with // the new value, newContents contents = newContents; } }



Wei-Jen Wang
2007-11-28