Move queue statistics to Worker

Just like the thread stats and poll stats earlier, the queue stats
are now moved to worker.

A litte refactoring still, and the polling will only work on local
data.
This commit is contained in:
Johan Wikman
2017-04-07 15:14:31 +03:00
parent 76825eb2c5
commit f952a11eb8
5 changed files with 140 additions and 64 deletions

View File

@ -53,7 +53,8 @@ void poll_init();
void poll_waitevents(int epoll_fd,
int thread_id,
THREAD_DATA* thread_data,
POLL_STATS* pollStats,
POLL_STATS* poll_stats,
QUEUE_STATS* queue_stats,
bool (*should_terminate)(void* data),
void* data);
void poll_set_maxwait(unsigned int);

View File

@ -197,10 +197,17 @@ public:
static int get_current_id();
private:
Worker(int id, int epoll_fd, THREAD_DATA* pThread_data, POLL_STATS* pPoll_stats);
Worker(int id,
int epoll_fd,
THREAD_DATA* pThread_data,
POLL_STATS* pPoll_stats,
QUEUE_STATS* pQueue_stats);
virtual ~Worker();
static Worker* create(int id, THREAD_DATA* pThread_data, POLL_STATS* pPoll_stats);
static Worker* create(int id,
THREAD_DATA* pThread_data,
POLL_STATS* pPoll_stats,
QUEUE_STATS* pQueue_stats);
void handle_message(MessageQueue& queue, const MessageQueue::Message& msg); // override
@ -211,6 +218,7 @@ private:
int m_epoll_fd; /*< The epoll file descriptor. */
THREAD_DATA* m_pThread_data; /*< The thread data of the worker. */
POLL_STATS* m_pPoll_stats; /*< Statistics for worker. */
QUEUE_STATS* m_pQueue_stats; /*< Statistics for queue. */
MessageQueue* m_pQueue; /*< The message queue of the worker. */
THREAD m_thread; /*< The thread handle of the worker. */
bool m_started; /*< Whether the thread has been started or not. */