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