LockCookie.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Threading / LockCookie.cs / 1305376 / LockCookie.cs

                            // ==++== 
//
//   Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--== 
//
// [....] 
/*============================================================ 
**
** Class:    LockCookie 
**
**
** 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()
        {
            // review - [....]! 
            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);
        }
    } 
}
 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK