Thread++
Client-Server Multithreading with C++
Public Member Functions | Protected Attributes | List of all members
CThread< CTaskClass > Class Template Reference

The thread class. More...

#include <Thread.h>

Inheritance diagram for CThread< CTaskClass >:
CCommon< CTaskClass >

Public Member Functions

 CThread (size_t)
 Constructor. More...
 
void operator() ()
 The code that gets run by each thread. More...
 

Protected Attributes

size_t m_nThreadId = 0
 Thread identifier.
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon< CTaskClass >
static CThreadSafeQueue< CTaskClass * > m_qRequest
 Request queue.
 
static CThreadSafeQueue< CTaskClass * > m_qResult
 Result queue.
 
static bool m_bForceExit = false
 Force exit flag.
 

Detailed Description

template<class CTaskClass>
class CThread< CTaskClass >

Values and functionality for the threads.

Template Parameters
CTaskClassTask descriptor.

Constructor & Destructor Documentation

◆ CThread()

template<class CTaskClass >
CThread< CTaskClass >::CThread ( size_t  n)

Constructor.

Parameters
nThread identifier.
Template Parameters
CTaskClassTask descriptor.

Member Function Documentation

◆ operator()()

template<class CTaskClass >
void CThread< CTaskClass >::operator()

The function executed by a thread, which repeatedly pops a task from the thread-safe request queue, calls its Perform() function, then places it on the result queue. It exits when the request queue is empty or when an exit is forced by CCommon<CTaskClass>::m_bForceExit being set to true.

Template Parameters
CTaskClassTask descriptor.