![]() |
Thread++
Client-Server Multithreading with C++
|
Thread safe queue. More...
#include <ThreadSafeQueue.h>
Public Member Functions | |
CThreadSafeQueue () | |
Constructor. More... | |
~CThreadSafeQueue () | |
Destructor. More... | |
void | Insert (const CTaskClass &element) |
Insert task at tail. More... | |
bool | Delete (CTaskClass &element) |
Delete task from head. More... | |
void | Flush () |
Flush out and discard all tasks in queue. More... | |
Private Attributes | |
std::mutex | m_stdMutex |
Mutex for thread safety. | |
std::queue< CTaskClass > | m_stdQueue |
The task descriptor queue. | |
A thread-safe queue of task descriptors for communicating between the threads and the thread manager. It uses an std::mutex
for safety.
CTaskClass | Task descriptor. |
CThreadSafeQueue< CTaskClass >::CThreadSafeQueue |
Default constructor.
CTaskClass | Task descriptor. |
CThreadSafeQueue< CTaskClass >::~CThreadSafeQueue |
Default destructor.
CTaskClass | Task descriptor. |
bool CThreadSafeQueue< CTaskClass >::Delete | ( | CTaskClass & | element | ) |
Delete and return a task descriptor from the queue. A mutex is used to ensure thread safety.
CTaskClass | Task descriptor. |
element | [OUT] The element deleted from the queue. |
void CThreadSafeQueue< CTaskClass >::Flush |
Flush all task descriptors out of the queue without processing them. A mutex is used to ensure thread safety.
CTaskClass | Task descriptor. |
void CThreadSafeQueue< CTaskClass >::Insert | ( | const CTaskClass & | element | ) |
Insert a task descriptor into the queue. A mutex is used to ensure thread safety.
CTaskClass | Task descriptor. |
element | The element to be inserted into the queue. |