Move thread data to workers

This is a step in the direction that any worker/thread related data
is the property of the worker/thread.
This commit is contained in:
Johan Wikman
2017-04-06 16:12:03 +03:00
parent 052975bccd
commit c11ca1c328
5 changed files with 71 additions and 58 deletions

View File

@ -52,6 +52,7 @@ void poll_init();
void poll_waitevents(int epoll_fd,
int thread_id,
THREAD_DATA* thread_data,
bool (*should_terminate)(void* data),
void* data);
void poll_set_maxwait(unsigned int);

View File

@ -197,10 +197,10 @@ public:
static int get_current_id();
private:
Worker(int id, int epoll_fd);
Worker(int id, int epoll_fd, THREAD_DATA* pThread_data);
virtual ~Worker();
static Worker* create(int id);
static Worker* create(int id, THREAD_DATA* pThread_data);
void handle_message(MessageQueue& queue, const MessageQueue::Message& msg); // override
@ -209,6 +209,7 @@ private:
private:
int m_id; /*< The id of the worker. */
int m_epoll_fd; /*< The epoll file descriptor. */
THREAD_DATA* m_pThread_data; /*< The thread data of the worker. */
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. */