Further remove use of the worker C-API

This commit is contained in:
Johan Wikman
2017-04-05 14:18:03 +03:00
parent f1e99a475a
commit 72eadff181
3 changed files with 12 additions and 26 deletions

View File

@ -68,22 +68,6 @@ enum mxs_worker_msg_id
*/
MXS_WORKER* mxs_worker_get(int worker_id);
/**
* Return the worker of the current thread.
*
* @return The worker instance or NULL if the calling thread is not associated
* with a worker.
*/
MXS_WORKER* mxs_worker_get_current();
/**
* Return the id of the worker of the current thread.
*
* @return The worker id or -1 if the calling thread is not associated
* with a worker.
*/
int mxs_worker_get_current_id();
/**
* Return the id of the worker.
*

View File

@ -98,7 +98,9 @@
#include "maxscale/session.h"
#include "maxscale/modules.h"
#include "maxscale/queuemanager.h"
#include "maxscale/worker.h"
#include "maxscale/worker.hh"
using maxscale::Worker;
/* A DCB with null values, used for initialization */
static DCB dcb_initialized;
@ -2267,7 +2269,7 @@ dcb_hangup_foreach(struct server* server)
intptr_t arg1 = (intptr_t)dcb_hangup_foreach_worker;
intptr_t arg2 = (intptr_t)server;
mxs_worker_broadcast_message(MXS_WORKER_MSG_CALL, arg1, arg2);
Worker::broadcast_message(MXS_WORKER_MSG_CALL, arg1, arg2);
}
/**
@ -3075,7 +3077,7 @@ void dcb_add_to_list(DCB *dcb)
* as that part is done in the final zombie processing.
*/
int worker_id = mxs_worker_get_current_id();
int worker_id = Worker::get_current_id();
if (worker_id == dcb->poll.thread.id)
{
@ -3092,13 +3094,13 @@ void dcb_add_to_list(DCB *dcb)
}
else
{
MXS_WORKER* worker = mxs_worker_get(dcb->poll.thread.id);
Worker* worker = Worker::get(dcb->poll.thread.id);
ss_dassert(worker);
intptr_t arg1 = (intptr_t)dcb_add_to_worker_list;
intptr_t arg2 = (intptr_t)dcb;
if (!mxs_worker_post_message(worker, MXS_WORKER_MSG_CALL, arg1, arg2))
if (!worker->post_message(MXS_WORKER_MSG_CALL, arg1, arg2))
{
MXS_ERROR("Could not post DCB to worker.");
}
@ -3113,7 +3115,7 @@ void dcb_add_to_list(DCB *dcb)
*/
static void dcb_remove_from_list(DCB *dcb)
{
ss_dassert(mxs_worker_get_current_id() == dcb->poll.thread.id);
ss_dassert(Worker::get_current_id() == dcb->poll.thread.id);
if (dcb == all_dcbs[dcb->poll.thread.id])
{

View File

@ -127,11 +127,11 @@ MXS_WORKER* mxs_worker_get(int worker_id)
return Worker::get(worker_id);
}
MXS_WORKER* mxs_worker_get_current()
Worker* Worker::get_current()
{
Worker* pWorker = NULL;
int worker_id = this_thread.current_worker_id;
int worker_id = get_current_id();
if (worker_id != WORKER_ABSENT_ID)
{
@ -141,7 +141,7 @@ MXS_WORKER* mxs_worker_get_current()
return pWorker;
}
int mxs_worker_get_current_id()
int Worker::get_current_id()
{
return this_thread.current_worker_id;
}
@ -226,7 +226,7 @@ void Worker::shutdown()
if (!m_shutdown_initiated)
{
if (mxs_worker_post_message(this, MXS_WORKER_MSG_SHUTDOWN, 0, 0))
if (post_message(MXS_WORKER_MSG_SHUTDOWN, 0, 0))
{
m_shutdown_initiated = true;
}