Public Member Functions | Public Attributes | Private Attributes

cmn_oneWRmanyRD Class Reference
[Common, basic classes, functions and types]

#include <thread.h>

Collaboration diagram for cmn_oneWRmanyRD:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 cmn_oneWRmanyRD ()
void WantWrite ()
 before write ask for permittion, if someone already set wantWrite then return false othervice wait for readers to complete and return true
void WantRead ()
 wait for writer to finish and read
void WriteDone ()
 WriteDone method release readers to.
void ReadDone ()
 ReadDone method decrement number of readers.

Public Attributes

 log_CLASSID_m

Private Attributes

bool m_wantWrite
int m_numOfReaders
cmn_Mutex m_oneWRmanyRD_x
cmn_Condition m_noReaders_c
cmn_Condition m_writeFinished_c

Detailed Description

Definition at line 373 of file thread.h.


Constructor & Destructor Documentation

cmn_oneWRmanyRD::cmn_oneWRmanyRD (  ) 

Definition at line 475 of file cmn_thread.cpp.


Member Function Documentation

void cmn_oneWRmanyRD::ReadDone (  ) 

ReadDone method decrement number of readers.

Definition at line 518 of file cmn_thread.cpp.

References cmn_Condition::Broadcast(), m_noReaders_c, m_numOfReaders, m_oneWRmanyRD_x, and m_wantWrite.

Here is the call graph for this function:

void cmn_oneWRmanyRD::WantRead (  ) 

wait for writer to finish and read

Definition at line 500 of file cmn_thread.cpp.

References m_numOfReaders, m_oneWRmanyRD_x, m_wantWrite, m_writeFinished_c, and cmn_Condition::Wait().

Here is the call graph for this function:

void cmn_oneWRmanyRD::WantWrite (  ) 

before write ask for permittion, if someone already set wantWrite then return false othervice wait for readers to complete and return true

Definition at line 487 of file cmn_thread.cpp.

References m_noReaders_c, m_numOfReaders, m_oneWRmanyRD_x, m_wantWrite, m_writeFinished_c, and cmn_Condition::Wait().

                                {
    cmn_MutexLock l(m_oneWRmanyRD_x);
    while (m_wantWrite) {
        m_writeFinished_c.Wait(); // someone already lock for write
    }
    m_wantWrite = true;
    while (m_numOfReaders > 0) {
        m_noReaders_c.Wait();
    }
}

Here is the call graph for this function:

void cmn_oneWRmanyRD::WriteDone (  ) 

WriteDone method release readers to.

Definition at line 510 of file cmn_thread.cpp.

References cmn_Condition::Broadcast(), m_oneWRmanyRD_x, m_wantWrite, and m_writeFinished_c.

Here is the call graph for this function:


Member Data Documentation

Definition at line 389 of file thread.h.

Definition at line 384 of file thread.h.

Referenced by ReadDone(), and WantWrite().

Definition at line 380 of file thread.h.

Referenced by ReadDone(), WantRead(), and WantWrite().

Definition at line 382 of file thread.h.

Referenced by ReadDone(), WantRead(), WantWrite(), and WriteDone().

Definition at line 378 of file thread.h.

Referenced by ReadDone(), WantRead(), WantWrite(), and WriteDone().

Definition at line 386 of file thread.h.

Referenced by WantRead(), WantWrite(), and WriteDone().


The documentation for this class was generated from the following files: