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

#include <cThreadLock.h>

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

Public Member Functions

 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
 

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

used with any data structure that may be locked for multi threaded access. These are fairly cheap and fast. Slow on actual collision. (but collide assumed to be infrequent)

Note
reentrant, multi locks on a single thread are allowed and counted.

Constructor & Destructor Documentation

◆ cThreadLockFast() [1/2]

Gray::cThreadLockFast::cThreadLockFast ( )
inlinenoexcept

◆ cThreadLockFast() [2/2]

Gray::cThreadLockFast::cThreadLockFast ( const cThreadLockFast a)
inlinenoexcept

Copy constructor should never actually be called! but if it is, just make a new copy that is not locked! pretend we copied stuff?

◆ ~cThreadLockFast()

Gray::cThreadLockFast::~cThreadLockFast ( )
inlinenoexcept

Member Function Documentation

◆ ClearThreadLockOwner()

bool Gray::cThreadLockFast::ClearThreadLockOwner ( THREADID_t  nTid)
inline

Special case if a thread is hard terminated. Only clear if nTid is the current owner.

◆ Lock()

void Gray::cThreadLockFast::Lock ( )

Take ownership if the lock is free or owned by the calling thread. Wait forever for a collision to clear.

Note
don't use inline. inline version of this made bad code? _MSC_VER

◆ LockTry()

bool Gray::cThreadLockFast::LockTry ( TIMESYSD_t  dwDelayMS = 0)

inline version of this made bad code? Take ownership if the lock is free or owned by the calling thread

◆ Unlock()

void Gray::cThreadLockFast::Unlock ( )
inline

inline version of this made bad code? ASSUME I own the lock. so this call doesn't really need to be thread safe.


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