// // Tries to wakeup a waiting writer. // // NOTE: This method is called with the spinlock held // and when the r/w lock is in the NonEntered state. // If a waiter is woken, the method releases the spin lock // and returns true; otherwise, the method returns false and // with the spinlock held. // private bool TryWakeupWriter() { while (!wrQueue.IsEmpty) { WaitNode w = wrQueue.Dequeue(); if (w.TryLock()) { // // Become the waiter the next owner of the write lock, // release the spinlock, unpark the waiter and return true. // writer = w.tid; slock.Exit(); w.Unpark(StParkStatus.Success); return(true); } } // // No writer can be released; so, return false with the // spinlock held. // return(false); }
// // Unparks all the wait nodes in the queue. // internal void UnparkAll() { WaitNode <Q> p = head; while (p != null) { p.Unpark(StParkStatus.Success); p = p.next; } }