worker Class Reference
[Communication]
Wraps the job queue to a basic worker like an simple actor pattern.
#include "worker.hpp"
Public Member Functions | |
void | add_msg (proxy_msg &msg) |
bool | is_running () |
void | join () |
void | start () |
worker (int max_msg) | |
~worker () | |
Protected Member Functions | |
virtual void | worker_thread ()=0 |
Protected Attributes | |
message_queue< proxy_msg > | m_job_queue |
bool | m_running |
Constructor & Destructor Documentation
worker::worker | ( | int | max_msg | ) |
Create a worker with a maximum job queue size.
- Parameters:
-
max_msg maximum size of the job queue
References HC_LOG_TRACE.
worker::~worker | ( | ) |
Member Function Documentation
void worker::add_msg | ( | proxy_msg & | msg | ) |
Add a message to the job queue.
References message_queue< T >::enqueue(), HC_LOG_DEBUG, HC_LOG_TRACE, m_job_queue, and proxy_msg::msg_type_to_string().
Referenced by proxy::end().
bool worker::is_running | ( | ) |
Check whether the receiver is running.
References HC_LOG_TRACE, and m_running.
void worker::join | ( | ) |
void worker::start | ( | ) |
virtual void worker::worker_thread | ( | ) | [protected, pure virtual] |
Worker thread to process the jobs.
Member Data Documentation
message_queue<proxy_msg> worker::m_job_queue [protected] |
bool worker::m_running [protected] |
The threads runs as long as m_running is true.
Referenced by is_running(), and start().