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

#include <cThreadMgr.h>

Inheritance diagram for GrayLib::cThreadMgr:
Gray::cSingleton< cThreadMgr > Gray::cSingletonStatic< TYPE > Gray::cSingletonRegister Gray::CObject Gray::cHeapObject Gray::IHeapObject

Public Member Functions

cThreadLockFastref_LockThreads () noexcept
 
cThreadPtr GetThreadForId (THREADID_t nThreadID) const noexcept
 
bool IsValidThreadId (THREADID_t nThreadID) noexcept
 
cThreadGetCurrentThread () const noexcept
 
HRESULT CheckAllThreads ()
 check m_aThreads against real system threads. More...
 
void Register (IThreadCloseHandler *pLocal)
 
void UnRegister (IThreadCloseHandler *pLocal)
 
- Public Member Functions inherited from Gray::CObject
virtual ~CObject ()
 
virtual bool isValidCheck () const noexcept
 < memory allocation and structure definitions are valid. More...
 
virtual void AssertValid () const
 < memory allocation and structure definitions are valid. More...
 
virtual void Serialize (cArchive &a)
 
- Public Member Functions inherited from Gray::cHeapObject
 cHeapObject ()
 
virtual ~cHeapObject ()
 
bool IsValidInsideN (INT_PTR index) const
 
bool IsValidInsidePtr (void const *pTest) const
 
virtual size_t GetHeapStatsThis (OUT ITERATE_t &iAllocCount) const
 
virtual bool isValidCheck () const noexcept
 

Protected Member Functions

 cThreadMgr ()
 
 ~cThreadMgr ()
 
- Protected Member Functions inherited from Gray::cSingleton< cThreadMgr >
 cSingleton (cThreadMgr *pObject, const TYPEINFO_t &rAddrCode=typeid(cThreadMgr)) noexcept
 
virtual ~cSingleton ()
 
- Protected Member Functions inherited from Gray::cSingletonStatic< TYPE >
 cSingletonStatic (TYPE *pObject) noexcept
 
virtual ~cSingletonStatic () noexcept
 
- Protected Member Functions inherited from Gray::cSingletonRegister
 cSingletonRegister (const TYPEINFO_t &rAddrCode) noexcept
 
virtual ~cSingletonRegister ()
 
void RegisterSingleton ()
 
- Protected Member Functions inherited from Gray::cHeapObject
const void * get_HeapPtr () const noexcept override
 Get the top level (outermost, freeable) class pointer. I can delete get_HeapPtr(). More...
 

Protected Attributes

cThreadLockFast m_LockThreads
 lock the whole threading system. to start/stop threads. More...
 
cArraySortHash< cThread, THREADID_t > m_aThreads
 just store array of pointers for each cThread. acts the same as a thread local type. More...
 
cArrayPtr< IThreadCloseHandlerm_aThreadCloseHandlers
 array of callbacks to notify when a thread closes. e.g. cleanup thread local stuff ? More...
 
- Protected Attributes inherited from Gray::cSingletonRegister
HMODULE m_hModuleLoaded
 What modules loaded this ? So singletons can be destroyed if DLL/SO unloads. More...
 

Friends

class cSingleton< cThreadMgr >
 
class cThread
 

Additional Inherited Members

- Static Public Member Functions inherited from Gray::cSingleton< cThreadMgr >
static cThreadMgr *__stdcall get_Single ()
 
static TYPE2 *__stdcall get_SingleT ()
 
static cThreadMgr &__stdcall I ()
 
- Static Public Member Functions inherited from Gray::cSingletonStatic< TYPE >
static bool isSingleCreated () noexcept
 
static TYPEget_SingleU () noexcept
 
static TYPEget_Single ()
 
template<class TYPE2 >
static TYPE2 *__stdcall get_SingleCast ()
 
static TYPEI () noexcept
 
- Static Public Member Functions inherited from Gray::cSingletonRegister
static void __stdcall ReleaseModule (HMODULE hMod)
 
- Static Public Attributes inherited from Gray::cSingletonRegister
static cThreadLockFast sm_LockSingle
 common lock for all cSingleton. More...
 
- Static Protected Attributes inherited from Gray::cSingletonStatic< TYPE >
static TYPEsm_pThe = nullptr
 pointer to the one and only object of this TYPE. ASSUME automatically init to = nullptr. More...
 

Detailed Description

Singleton structure for tracking all active threads for the app. an array of cThread structures. used to cross reference threads with thread locals such that thread locals are destroyed when the thread is destroyed.

Constructor & Destructor Documentation

◆ cThreadMgr()

GrayLib::cThreadMgr::cThreadMgr ( )
protected

◆ ~cThreadMgr()

GrayLib::cThreadMgr::~cThreadMgr ( )
protected

Member Function Documentation

◆ CheckAllThreads()

HRESULT GrayLib::cThreadMgr::CheckAllThreads ( )

check m_aThreads against real system threads.

Threads can get destroyed without proper notification. periodically check to see if the threads are still truly valid in the system ?

◆ GetCurrentThread()

cThread * GrayLib::cThreadMgr::GetCurrentThread ( ) const
noexcept

◆ GetThreadForId()

cThreadPtr GrayLib::cThreadMgr::GetThreadForId ( THREADID_t  nThreadID) const
noexcept

◆ IsValidThreadId()

bool GrayLib::cThreadMgr::IsValidThreadId ( THREADID_t  nThreadID)
inlinenoexcept

Is this a valid thread id in my list? might still be valid system id ?

◆ ref_LockThreads()

cThreadLockFast& GrayLib::cThreadMgr::ref_LockThreads ( )
inlinenoexcept

lock the whole threading system. to start/stop/register threads. Danger!

◆ Register()

void GrayLib::cThreadMgr::Register ( IThreadCloseHandler pLocal)

register a new type of thread local. stores 1 per new thread.

◆ UnRegister()

void GrayLib::cThreadMgr::UnRegister ( IThreadCloseHandler pLocal)

get rid of a thread local data type for all threads.

Friends And Related Function Documentation

◆ cSingleton< cThreadMgr >

friend class cSingleton< cThreadMgr >
friend

◆ cThread

friend class cThread
friend

Member Data Documentation

◆ m_aThreadCloseHandlers

cArrayPtr<IThreadCloseHandler> GrayLib::cThreadMgr::m_aThreadCloseHandlers
protected

array of callbacks to notify when a thread closes. e.g. cleanup thread local stuff ?

◆ m_aThreads

cArraySortHash<cThread, THREADID_t> GrayLib::cThreadMgr::m_aThreads
protected

just store array of pointers for each cThread. acts the same as a thread local type.

◆ m_LockThreads

cThreadLockFast GrayLib::cThreadMgr::m_LockThreads
mutableprotected

lock the whole threading system. to start/stop threads.


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