For EZ property sets, added a setter that performs an "atomic" test-and-set:

it's atomic in the sense that a single server event will test the variable, 
and only set it if the previous value was null (i.e. didn't exist). 
This allows for a level of elementary synchronization between the clients.

The new function on EZGameControl is:
  _gameCtrl.testAndSet (propertyName, newValue[, index])

I hoped to generalize this to test against arbitrary values, but that's 
significantly harder, since properties accept numerous types as values,
and those can have different representations on the client and the server.
So it remains a check against null until we need to generalize it. :)





git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@193 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Robert Zubeck
2007-02-15 21:55:49 +00:00
parent 720a409185
commit bdfcd156ab
17 changed files with 136 additions and 91 deletions
+15 -2
View File
@@ -153,11 +153,24 @@ public class EZGameControl extends EventDispatcher
}
/**
* Set a property that will be distributed.
* Set a property that will be distributed.
*/
public function set (propName :String, value :Object, index :int = -1) :void
{
callEZCode("setProperty_v1", propName, value, index);
callEZCode("setProperty_v2", propName, value, index, false);
}
/**
* Set a property that will be distributed, but only if it was null before.
*
* The operation is 'atomic', in the sense that testing and setting take place
* during the same server event. In comparison, a separate 'get' followed by
* a 'set' operation would involve two events with two network round-trips,
* and no guarantee that the value won't change between the events.
*/
public function testAndSet (propName :String, value :Object, index :int = -1) :void
{
callEZCode("setProperty_v2", propName, value, index, true);
}
/**