On Wed, Oct 1, 2014 at 5:10 PM, Jordan Zimmerman <[email protected] > wrote:
> But how would a client of SharedValue know they had the latest "base" > value on which to compute an update value? > > You would try to change the value and, if it returns false, you read the > value again. > I don't think this actually happens, is the problem. The event sequence looks like this: 1) User calls sharedValue.getData() to get value A. 2) Server records a value change to B 3) SharedValue.readValue() runs, updating sharedValue internal state to B. 4) Meanwhile user computes A -> A'. 5) User calls sharedValue.trySetValue(A'). This succeeds because sharedValue thinks it's up to date; it has no idea that the user is setting a value based on old data. By contrast, DistributedAtomicValue.compareAndSet(A, A') would have failed because it can explicitly compare the user's snapshot of the previous state.
