Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

void PReadWriteMutex::EndRead (  ) 

This function attempts to release the mutex for reading.

Definition at line 2425 of file osutils.cxx.

Referenced by PSafeObject::UnlockReadOnly(), and PReadWaitAndSignal::~PReadWaitAndSignal().

{
  // Get the nested thread info structure for the curent thread
  Nest * nest = GetNest();

  // If don't have an active read or write lock or there is a write lock but
  // the StartRead() was never called, then assert and ignore call.
  if (nest == NULL || nest->readerCount == 0) {
    PAssertAlways("Unbalanced PReadWriteMutex::EndRead()");
    return;
  }

  // One less nested lock by this thread, note this does not
  // need to be mutexed as it is always in the context of a single thread.
  nest->readerCount--;

  // If this is a nested read or a write lock is present then we don't do the
  // real unlock, the decrement is enough.
  if (nest->readerCount > 0 || nest->writerCount > 0)
    return;

  // Do text book read lock
  InternalEndRead();

  // At this point all read and write locks are gone for this thread so we can
  // reclaim the memory.
  EndNest();
}


Generated by  Doxygen 1.6.0   Back to index