コード例 #1
0
ファイル: VBox.cs プロジェクト: AndreasKarlsen/Thesis
        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));
            }
        }
コード例 #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));
     }
 }