Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cThreadLockRW Class Reference

#include <cThreadLockRW.h>

Inheritance diagram for Gray::cThreadLockRW:
Gray::cThreadLockFast Gray::cThreadLockBase Gray::cLockableBase Gray::cNonCopyable Gray::cThreadLockableRW

Public Member Functions

 cThreadLockRW ()
 
 ~cThreadLockRW ()
 
void IncReadLockCount ()
 
void DecReadLockCount ()
 
- Public Member Functions inherited from Gray::cThreadLockFast
 cThreadLockFast () noexcept
 
 cThreadLockFast (const cThreadLockFast &a) noexcept
 
 ~cThreadLockFast () noexcept
 
bool ClearThreadLockOwner (THREADID_t nTid)
 
void Lock ()
 
bool LockTry (TIMESYSD_t dwDelayMS=0)
 
void Unlock ()
 
- Public Member Functions inherited from Gray::cThreadLockBase
 cThreadLockBase () noexcept
 
bool isLocked () const noexcept
 
THREADID_t get_ThreadLockOwner () const
 
bool isThreadLockedByCurrent () const noexcept
 

Public Attributes

cInterlockedInt m_nReadLockCount
 How many readers (for orig m_nLockThreadID) More...
 
cInterlockedInt m_nOtherReadLockCount
 How many outside (not on orig thread) readers. More...
 
bool m_bLostOrder
 can't figure who is thread. More...
 

Friends

class cThreadLockRWTests
 

Additional Inherited Members

- Protected Member Functions inherited from Gray::cThreadLockBase
THREADID_t __DECL_ALIGN (_SIZEOF_THREADID) m_nLockThreadID
 The thread that has the lock. cThreadId:k_NULL is not locked. More...
 
- Protected Member Functions inherited from Gray::cLockableBase
 cLockableBase () noexcept
 
 ~cLockableBase ()
 
LONG get_LockCount () const
 
bool isLocked () const
 
void IncLockCount ()
 
LONG DecLockCount ()
 
void Lock ()
 
LONG Unlock ()
 
- Protected Member Functions inherited from Gray::cNonCopyable
 cNonCopyable () noexcept
 Force the use of Factory creation via protected constructor. More...
 
 ~cNonCopyable () noexcept
 

Detailed Description

Todo:
cThreadLockRW cheap RW declaring thread locking mechanism. Recursive and upgradeable (i.e. i can start with read and upgrade to write permissions on the same thread) Only one thread may write lock something. multiple read locks may be released out of order, i.e first read locker releases with other readers = unknown read thread. similar to : Linux thread locking pthread_rwlock_wrlock()

RULES: FR = first thread reader. FW = first thread writer. (just like a normal thread lock) OR = other thread reader OW = other thread writer. if the first locker is write, FR=go, FW=go, OR=wait, OW=wait if the first locker is reader, FR=go, FW=go, OR=go, OW=wait.

Constructor & Destructor Documentation

◆ cThreadLockRW()

Gray::cThreadLockRW::cThreadLockRW ( )
inline

◆ ~cThreadLockRW()

Gray::cThreadLockRW::~cThreadLockRW ( )
inline

Member Function Documentation

◆ DecReadLockCount()

void Gray::cThreadLockRW::DecReadLockCount ( )
inline

◆ IncReadLockCount()

void Gray::cThreadLockRW::IncReadLockCount ( )
inline

Friends And Related Function Documentation

◆ cThreadLockRWTests

friend class cThreadLockRWTests
friend

Member Data Documentation

◆ m_bLostOrder

bool Gray::cThreadLockRW::m_bLostOrder

can't figure who is thread.

◆ m_nOtherReadLockCount

cInterlockedInt Gray::cThreadLockRW::m_nOtherReadLockCount

How many outside (not on orig thread) readers.

◆ m_nReadLockCount

cInterlockedInt Gray::cThreadLockRW::m_nReadLockCount

How many readers (for orig m_nLockThreadID)


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