MCProxy

worker Class Reference
[Communication]

Wraps the job queue to a basic worker like an simple actor pattern.

#include "worker.hpp"

List of all members.

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_msgm_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 (  ) 

Blocked until the worker thread stopped.

References HC_LOG_TRACE.

Referenced by proxy::end().

void worker::start (  ) 

Start the worker.

References HC_LOG_TRACE, and m_running.

Referenced by proxy::init().

virtual void worker::worker_thread (  )  [protected, pure virtual]

Worker thread to process the jobs.


Member Data Documentation

Job queue to process proxy_msg.

Referenced by add_msg().

bool worker::m_running [protected]

The threads runs as long as m_running is true.

Referenced by is_running(), and start().