The thread state is now a property of the worker

A worker's state is not statistics, but transient information.
This commit is contained in:
Johan Wikman
2017-04-18 12:56:23 +03:00
parent effa2f5674
commit 722d6da46f
4 changed files with 49 additions and 59 deletions

View File

@ -27,6 +27,15 @@ class Worker : public MXS_WORKER
Worker& operator = (const Worker&);
public:
enum state_t
{
STOPPED,
IDLE,
POLLING,
PROCESSING,
ZPROCESSING
};
/**
* Initialize the worker mechanism.
*
@ -54,6 +63,18 @@ public:
return m_id;
}
/**
* Returns the state of the worker.
*
* @return The current state.
*
* @attentions The state might have changed the moment after the function returns.
*/
state_t state() const
{
return m_state;
}
/**
* Add a file descriptor to the epoll instance of the worker.
*
@ -227,15 +248,11 @@ private:
static void thread_main(void* arg);
static void poll_waitevents(int epoll_fd,
int thread_id,
POLL_STATS* poll_stats,
QUEUE_STATS* queue_stats,
bool (*should_shutdown)(void* data),
void* data);
void poll_waitevents(POLL_STATS* poll_stats, QUEUE_STATS* queue_stats);
private:
int m_id; /*< The id of the worker. */
state_t m_state; /*< The state of the worker */
int m_epoll_fd; /*< The epoll file descriptor. */
POLL_STATS* m_pPoll_stats; /*< Statistics for worker. */
QUEUE_STATS* m_pQueue_stats; /*< Statistics for queue. */