Exemple #1
0
        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);
        }
Exemple #2
0
        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));
            }
        }
Exemple #3
0
        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);
        }
Exemple #4
0
 internal override void Clean()
 {
     Next = null;
 }
Exemple #5
0
 internal VBoxBody(T value, int version, VBoxBody <T> next)
     : this(value, version)
 {
     Next = next;
 }
Exemple #6
0
 public VBox(T value)
 {
     _body = new VBoxBody <T>(value, 0);
 }