diff options
Diffstat (limited to 'src/mscorlib/src/System/Threading/LockCookie.cs')
-rw-r--r-- | src/mscorlib/src/System/Threading/LockCookie.cs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/mscorlib/src/System/Threading/LockCookie.cs b/src/mscorlib/src/System/Threading/LockCookie.cs new file mode 100644 index 0000000000..c1fbfd828e --- /dev/null +++ b/src/mscorlib/src/System/Threading/LockCookie.cs @@ -0,0 +1,57 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// +/*============================================================ +** +** +** +** Purpose: Defines the lock that implements +** single-writer/multiple-reader semantics +** +** +===========================================================*/ + +namespace System.Threading { + + using System; + [System.Runtime.InteropServices.ComVisible(true)] + public struct LockCookie + { + private int _dwFlags; + private int _dwWriterSeqNum; + private int _wReaderAndWriterLevel; + private int _dwThreadID; + + public override int GetHashCode() + { + return _dwFlags + _dwWriterSeqNum + _wReaderAndWriterLevel + _dwThreadID; + } + + public override bool Equals(Object obj) + { + if (obj is LockCookie) + return Equals((LockCookie)obj); + else + return false; + } + + public bool Equals(LockCookie obj) + { + return obj._dwFlags == _dwFlags && obj._dwWriterSeqNum == _dwWriterSeqNum && + obj._wReaderAndWriterLevel == _wReaderAndWriterLevel && obj._dwThreadID == _dwThreadID; + } + + public static bool operator ==(LockCookie a, LockCookie b) + { + return a.Equals(b); + } + + public static bool operator !=(LockCookie a, LockCookie b) + { + return !(a == b); + } + } +} + |