Example #1
0
            public void EnterReadLock()
            {
                SpinWait sw = new SpinWait();

                do
                {
                    while ((rwlock & (RwWrite | RwWait)) > 0)
                    {
                        sw.SpinOnce();
                    }

                    if ((Interlocked.Add(ref rwlock, RwRead) & (RwWait | RwWait)) == 0)
                    {
                        return;
                    }

                    Interlocked.Add(ref rwlock, -RwRead);
                } while (true);
            }
Example #2
0
 public void ExitWriteLock()
 {
     Interlocked.Add(ref rwlock, -RwWrite);
 }
Example #3
0
 public void ExitReadLock()
 {
     Interlocked.Add(ref rwlock, -RwRead);
 }