Example #1
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));
            }
        }
Example #2
0
 internal VBoxBody <T> GetBody(int version)
 {
     if (this.Version == version)
     {
         return(this);
     }
     else if (this.Version < version)
     {
         return(null);
     }
     else
     {
         return(Next.GetBody(version));
     }
 }