public void UnsafeRemove(CollectibleNode node)
 {
     if (directory.ContainsKey(node.GetKey()))
     {
         directory.Remove(node.GetKey());
     }
 }
        // This method must be called inside a writable lock
        public void UnsafeAdd(CollectibleNode node)
        {
            Fx.Assert(rwLock.IsWriteLockHeld, "This method can be called only when the WriterLock is acquired");

            writeCounter++;
            directory.Add(node.GetKey(), node);
            node.LastCounter = Interlocked.Increment(ref counter);
        }
        public void Touch(TKey key)
        {
            rwLock.EnterReadLock();
            try
            {
                CollectibleNode node = UnsafeGet(key);

                if (node != null)
                {
                    // Record the last counter in the node. We don't take a writer lock here because the counter does
                    // not have to be very accurate.
                    node.LastCounter = Interlocked.Increment(ref counter);
                }
            }
            finally
            {
                rwLock.ExitReadLock();
            }
        }
 public static int CounterLessThan(CollectibleNode x, CollectibleNode y)
 {
     return(x.LastCounter - y.LastCounter);
 }