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

void PReadWriteMutex::EndWrite (  ) 

This function attempts to release the mutex for writing. Note, if the same thread had a read lock when the StartWrite() was called which has not yet been released by an EndRead() call then this will reacquire the read lock.

It should also be noted that a consequence of this is that another thread may acquire the write lock before the thread that regains the read lock. Thus it is impossibly to go straight from a write lock to read lock without the possiblility of the object being changed and application logic should take this into account.

Definition at line 2504 of file osutils.cxx.

References PSemaphore::Signal().

Referenced by PSafeObject::UnlockReadWrite(), and PWriteWaitAndSignal::~PWriteWaitAndSignal().

  // 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 read lock but
  // the StartWrite() was never called, then assert and ignore call.
  if (nest == NULL || nest->writerCount == 0) {
    PAssertAlways("Unbalanced PReadWriteMutex::EndWrite()");

  // 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.

  // If this is a nested write lock then the decrement is enough and we
  // don't do the actual write unlock.
  if (nest->writerCount > 0)

  // Begin text book write unlock


  if (writerCount == 0)

  // End of text book write unlock

  // Now check to see if there was a read lock present for this thread, if so
  // then reacquire the read lock (not changing the count) otherwise clean up the
  // memory for the nested thread info structure
  if (nest->readerCount > 0)

Generated by  Doxygen 1.6.0   Back to index