MXS-1754 Rename mxs::Worker to mxs::RoutingWorker
A new class mxs::Worker will be introduced and mxs::RoutingWorker will be inherited from that. mxs::Worker will basically only be a thread with a message-loop. Once available, all current non-worker threads (but the one implicitly created by microhttpd) can be creating by inheriting from that; in practice that means the housekeeping thread, all monitor threads and possibly the logging thread. The benefit of this arrangement is that there then will be a general mechanism for cross thread communication without having to use any shared data structures.
This commit is contained in:
@ -19,7 +19,7 @@ namespace maxscale
|
||||
{
|
||||
|
||||
class MessageQueue;
|
||||
class Worker;
|
||||
class RoutingWorker;
|
||||
|
||||
/**
|
||||
* An instance of @c MessageQueueMessage can be sent over a @c MessageQueue from
|
||||
@ -180,7 +180,7 @@ public:
|
||||
* @attention If the message queue is currently added to a worker, it
|
||||
* will first be removed from that worker.
|
||||
*/
|
||||
bool add_to_worker(Worker* pWorker);
|
||||
bool add_to_worker(RoutingWorker* pWorker);
|
||||
|
||||
/**
|
||||
* Removes the message queue from the worker it is currently added to.
|
||||
@ -188,7 +188,7 @@ public:
|
||||
* @return The worker the message queue was associated with, or NULL
|
||||
* if it was not associated with any.
|
||||
*/
|
||||
Worker* remove_from_worker();
|
||||
RoutingWorker* remove_from_worker();
|
||||
|
||||
private:
|
||||
MessageQueue(Handler* pHandler, int read_fd, int write_fd);
|
||||
@ -198,10 +198,10 @@ private:
|
||||
static uint32_t poll_handler(MXS_POLL_DATA* pData, int thread_id, uint32_t events);
|
||||
|
||||
private:
|
||||
Handler& m_handler;
|
||||
int m_read_fd;
|
||||
int m_write_fd;
|
||||
Worker* m_pWorker;
|
||||
Handler& m_handler;
|
||||
int m_read_fd;
|
||||
int m_write_fd;
|
||||
RoutingWorker* m_pWorker;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -422,13 +422,15 @@ private:
|
||||
Average1 m_load_1_second; /*< The load during the last 1-second period. */
|
||||
};
|
||||
|
||||
class RoutingWorker;
|
||||
typedef RoutingWorker Worker;
|
||||
|
||||
class Worker : public MXS_WORKER
|
||||
class RoutingWorker : public MXS_WORKER
|
||||
, private MessageQueue::Handler
|
||||
, private MXS_POLL_DATA
|
||||
{
|
||||
Worker(const Worker&);
|
||||
Worker& operator = (const Worker&);
|
||||
RoutingWorker(const RoutingWorker&);
|
||||
RoutingWorker& operator = (const RoutingWorker&);
|
||||
|
||||
public:
|
||||
typedef WORKER_STATISTICS STATISTICS;
|
||||
@ -833,14 +835,14 @@ public:
|
||||
* @return The corresponding worker instance, or NULL if the id does
|
||||
* not correspond to a worker.
|
||||
*/
|
||||
static Worker* get(int worker_id);
|
||||
static RoutingWorker* get(int worker_id);
|
||||
|
||||
/**
|
||||
* Return the worker associated with the current thread.
|
||||
*
|
||||
* @return The worker instance, or NULL if the current thread does not have a worker.
|
||||
*/
|
||||
static Worker* get_current();
|
||||
static RoutingWorker* get_current();
|
||||
|
||||
/**
|
||||
* Return the worker id associated with the current thread.
|
||||
@ -865,11 +867,11 @@ public:
|
||||
static void set_maxwait(unsigned int maxwait);
|
||||
|
||||
private:
|
||||
Worker(int id,
|
||||
int epoll_fd);
|
||||
virtual ~Worker();
|
||||
RoutingWorker(int id,
|
||||
int epoll_fd);
|
||||
virtual ~RoutingWorker();
|
||||
|
||||
static Worker* create(int id, int epoll_listener_fd);
|
||||
static RoutingWorker* create(int id, int epoll_listener_fd);
|
||||
|
||||
void delete_zombies();
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
namespace maxscale
|
||||
{
|
||||
|
||||
class Worker;
|
||||
class RoutingWorker;
|
||||
|
||||
/**
|
||||
* A WorkerTask represents a task to be performed by a Worker.
|
||||
@ -38,7 +38,7 @@ public:
|
||||
* @attention As the function is called by a worker, the body of `execute`
|
||||
* should execute quickly and not perform any blocking operations.
|
||||
*/
|
||||
virtual void execute(Worker& worker) = 0;
|
||||
virtual void execute(RoutingWorker& worker) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -69,10 +69,10 @@ protected:
|
||||
* @attention As the function is called by a worker, the body of `execute`
|
||||
* should execute quickly and not perform any blocking operations.
|
||||
*/
|
||||
virtual void execute(Worker& worker) = 0;
|
||||
virtual void execute(RoutingWorker& worker) = 0;
|
||||
|
||||
private:
|
||||
friend class Worker;
|
||||
friend class RoutingWorker;
|
||||
|
||||
void inc_ref();
|
||||
void dec_ref();
|
||||
|
||||
Reference in New Issue
Block a user