Issued by the VersionList static class, tells holders which version of data they should read. The VersionList will keep track of issued tickets for the purpose of safe trimming of old versions.
コード例 #1
0
ファイル: VersionList.cs プロジェクト: scpedoc/Shielded
        /// <summary>
        /// After no reading will be done for the given reader ticket, release it with this method.
        /// </summary>
        public static void ReleaseReaderTicket(ref ReadTicket ticket)
        {
            var node = (VersionEntry)ticket;

            ticket = null;
            Interlocked.Decrement(ref node.ReaderCount);
        }
コード例 #2
0
ファイル: VersionList.cs プロジェクト: jbakic/Shielded
 /// <summary>
 /// Reader should keep a reference to his ticket, and release it with a call
 /// to <see cref="ReleaseReaderTicket"/> when done.
 /// </summary>
 public static void GetReaderTicket(out ReadTicket ticket)
 {
     try {} finally
     {
         while (true)
         {
             var curr = _current;
             // trimming sets this to int.MinValue, so unless 2 billion threads are doing this
             // simultaneously, we're safe.
             if (Interlocked.Increment(ref curr.ReaderCount) > 0)
             {
                 ticket = curr;
                 break;
             }
         }
     }
 }
コード例 #3
0
ファイル: VersionList.cs プロジェクト: scpedoc/Shielded
 /// <summary>
 /// Reader should keep a reference to his ticket, and release it with a call
 /// to <see cref="ReleaseReaderTicket"/> when done.
 /// </summary>
 public static void GetReaderTicket(out ReadTicket ticket)
 {
     try {} finally
     {
         while (true)
         {
             var curr = _current;
             // trimming sets this to int.MinValue, so unless 2 billion threads are doing this
             // simultaneously, we're safe.
             if (Interlocked.Increment(ref curr.ReaderCount) > 0)
             {
                 ticket = curr;
                 break;
             }
         }
     }
 }
コード例 #4
0
ファイル: VersionList.cs プロジェクト: jbakic/Shielded
 /// <summary>
 /// After no reading will be done for the given reader ticket, release it with this method.
 /// </summary>
 public static void ReleaseReaderTicket(ref ReadTicket ticket)
 {
     var node = (VersionEntry)ticket;
     ticket = null;
     Interlocked.Decrement(ref node.ReaderCount);
 }