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

BOOL PSafeObject::LockReadOnly (  )  const

Lock the object for Read Only access. This will lock the object in read only mode. Multiple threads may lock the object read only, but only one thread can lock for read/write. Also, no read only threads can be present for the read/write lock to occur and no read/write lock can be present for any read only locks to occur.

If the function returns FALSE, then the object has been flagged for deletion and the calling thread should immediately cease use of the object, possibly executing the SafeDereference() function to remove any references it may have acquired.

It is expected that the caller had already called the SafeReference() function (directly or implicitly) before calling this function. It is recommended that the PSafePtr<> class is used to automatically manage the reference counting and locking of objects.

Definition at line 142 of file safecoll.cxx.

References PReadWriteMutex::StartRead().

{
  safetyMutex.Wait();

  if (safelyBeingRemoved) {
    safetyMutex.Signal();
    return FALSE;
  }

  safetyMutex.Signal();
  safeInUse->StartRead();
  return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index