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.
Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
 /// <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;
             }
         }
     }
 }
Beispiel #3
0
 /// <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;
             }
         }
     }
 }
Beispiel #4
0
 /// <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);
 }