All worker data moved to Worker class
With the exception of the poll structure.
This commit is contained in:
@ -21,13 +21,6 @@ MXS_BEGIN_DECLS
|
|||||||
typedef struct mxs_worker
|
typedef struct mxs_worker
|
||||||
{
|
{
|
||||||
MXS_POLL_DATA m_poll; /*< The poll data used by the polling mechanism. */
|
MXS_POLL_DATA m_poll; /*< The poll data used by the polling mechanism. */
|
||||||
int m_id; /*< The id of the worker. */
|
|
||||||
int m_read_fd; /*< The file descriptor the worked reads from. */
|
|
||||||
int m_write_fd; /*< The file descriptor used for sending data to the worker. */
|
|
||||||
THREAD m_thread; /*< The thread handle of the worker. */
|
|
||||||
bool m_started; /*< Whether the thread has been started or not. */
|
|
||||||
bool m_should_shutdown; /*< Whether shutdown should be performed. */
|
|
||||||
bool m_shutdown_initiated; /*< Whether shutdown has been initated. */
|
|
||||||
} MXS_WORKER;
|
} MXS_WORKER;
|
||||||
|
|
||||||
enum mxs_worker_msg_id
|
enum mxs_worker_msg_id
|
||||||
@ -75,10 +68,7 @@ MXS_WORKER* mxs_worker_get(int worker_id);
|
|||||||
*
|
*
|
||||||
* @return The id of the worker.
|
* @return The id of the worker.
|
||||||
*/
|
*/
|
||||||
static inline int mxs_worker_id(MXS_WORKER* pWorker)
|
int mxs_worker_id(MXS_WORKER* pWorker);
|
||||||
{
|
|
||||||
return pWorker->m_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post a message to a worker.
|
* Post a message to a worker.
|
||||||
|
@ -23,9 +23,6 @@ MXS_BEGIN_DECLS
|
|||||||
*
|
*
|
||||||
* @return True, if the worker should shut down, false otherwise.
|
* @return True, if the worker should shut down, false otherwise.
|
||||||
*/
|
*/
|
||||||
static inline bool mxs_worker_should_shutdown(MXS_WORKER* worker)
|
bool mxs_worker_should_shutdown(MXS_WORKER* worker);
|
||||||
{
|
|
||||||
return worker->m_should_shutdown;
|
|
||||||
}
|
|
||||||
|
|
||||||
MXS_END_DECLS
|
MXS_END_DECLS
|
||||||
|
@ -63,11 +63,12 @@ static bool modules_thread_init();
|
|||||||
static void modules_thread_finish();
|
static void modules_thread_finish();
|
||||||
|
|
||||||
Worker::Worker(int id, int read_fd, int write_fd)
|
Worker::Worker(int id, int read_fd, int write_fd)
|
||||||
|
: m_id(id)
|
||||||
|
, m_read_fd(read_fd)
|
||||||
|
, m_write_fd(write_fd)
|
||||||
{
|
{
|
||||||
m_poll.handler = &Worker::poll_handler;
|
m_poll.handler = &Worker::poll_handler;
|
||||||
m_id = id;
|
|
||||||
m_read_fd = read_fd;
|
|
||||||
m_write_fd = write_fd;
|
|
||||||
m_thread = 0;
|
m_thread = 0;
|
||||||
m_started = false;
|
m_started = false;
|
||||||
m_should_shutdown = false;
|
m_should_shutdown = false;
|
||||||
@ -115,6 +116,16 @@ void Worker::finish()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mxs_worker_id(MXS_WORKER* pWorker)
|
||||||
|
{
|
||||||
|
return static_cast<Worker*>(pWorker)->id();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mxs_worker_should_shutdown(MXS_WORKER* pWorker)
|
||||||
|
{
|
||||||
|
return static_cast<Worker*>(pWorker)->should_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
Worker* Worker::get(int worker_id)
|
Worker* Worker::get(int worker_id)
|
||||||
{
|
{
|
||||||
ss_dassert(worker_id < this_unit.n_workers);
|
ss_dassert(worker_id < this_unit.n_workers);
|
||||||
|
Reference in New Issue
Block a user