internal void Lock(TensorLocation location) { lock (syncRoot) { if (activeScopeLocation != location && activeScopeCount != 0) { throw new InvalidOperationException("Cannot request a tensor lock. There is already an scope active with a different location."); } Interlocked.Increment(ref activeScopeCount); activeScopeLocation = location; } }
internal void Unlock(TensorLocation location) { lock (syncRoot) { if (activeScopeLocation != location) { throw new InvalidOperationException("Cannot request a tensor unlock on a different location."); } if (activeScopeCount == 0) { throw new InvalidOperationException("Cannot request a tensor unlock. There is no scope active to support the request."); } Interlocked.Decrement(ref activeScopeCount); activeScopeLocation = location; } }
internal void Unlock(TensorLocation location) { lock (syncRoot) { if (activeScopeLocation != location) throw new InvalidOperationException("Cannot request a tensor unlock on a different location."); if (activeScopeCount == 0) throw new InvalidOperationException("Cannot request a tensor unlock. There is no scope active to support the request."); Interlocked.Decrement(ref activeScopeCount); activeScopeLocation = location; } }
internal void Lock(TensorLocation location) { lock (syncRoot) { if (activeScopeLocation != location && activeScopeCount != 0) throw new InvalidOperationException("Cannot request a tensor lock. There is already an scope active with a different location."); Interlocked.Increment(ref activeScopeCount); activeScopeLocation = location; } }