示例#1
0
        // IMPORTANT: lock() does not guarantee fairness and is vulnerable to thread starvation
        private void SetNoAccessIfNeeded()
        {
            lock (accessLock)
            {
                accessCounter--;

                // Only set no access if we're the last one trying to access this potentially-shared Secret
                if (accessCounter == 0)
                {
                    allocator.SetNoAccess(pointer, length);
                }
            }
        }
 private void SetNoAccessIfNeeded()
 {
     // accessLock protects concurrent readers from changing access permissions at the same time
     // while holding the pointerLock in read mode
     lock (accessLock)
     {
         // Only set no access if we're the last one trying to access this potentially-shared Secret
         accessCounter--;
         if (accessCounter == 0)
         {
             allocator.SetNoAccess(pointer, length);
         }
     }
 }