internal override BaseVBoxBody Install(object value, int version) { _body = new VBoxBody <T>((T)value, version, _body); if (_listeners.Count == 0) { return(_body); } var temp = _listeners; foreach (var retryLatch in temp) { retryLatch.Open(retryLatch.Era); } ImmutableList <IRetryLatch> initial; do { initial = _listeners; } while (initial != Interlocked.CompareExchange(ref _listeners, ImmutableList <IRetryLatch> .Empty, initial)); return(_body); }
internal VBoxBody <T> CASBody(VBoxBody <T> expected, VBoxBody <T> newBody) { if (expected == Interlocked.CompareExchange <VBoxBody <T> >(ref _body, newBody, expected)) { if (_listeners.Count == 0) { return(newBody); } var temp = _listeners; foreach (var retryLatch in temp) { retryLatch.Open(retryLatch.Era); } ImmutableList <IRetryLatch> initial; do { initial = _listeners; } while (initial != Interlocked.CompareExchange(ref _listeners, ImmutableList <IRetryLatch> .Empty, initial)); return(newBody); } else { return(_body.GetBody(newBody.Version)); } }
internal override BaseVBoxBody Commit(object value, int version) { var currHead = _body; var existingBody = currHead.GetBody(version); if (existingBody == null) { var newBody = new VBoxBody <T>((T)value, version, currHead); existingBody = CASBody(currHead, newBody); } return(existingBody); }
internal override void Clean() { Next = null; }
internal VBoxBody(T value, int version, VBoxBody <T> next) : this(value, version) { Next = next; }
public VBox(T value) { _body = new VBoxBody <T>(value, 0); }