MXS-2002 Rename Worker::post() to Worker::execute()
The main point is that tasks/functions are executed, not that they are posted.
This commit is contained in:
parent
3013adb14f
commit
e9758ebaf1
@ -706,13 +706,14 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts a task to a worker for execution.
|
||||
* Executes a task on the worker thread.
|
||||
*
|
||||
* @param pTask The task to be executed.
|
||||
* @param pSem If non-NULL, will be posted once the task's `execute` return.
|
||||
* @param mode Execution mode
|
||||
*
|
||||
* @return True if the task could be posted (i.e. not executed), false otherwise.
|
||||
* @return True if the task could be posted to the worker (i.e. not executed yet),
|
||||
false otherwise.
|
||||
*
|
||||
* @attention The instance must remain valid for as long as it takes for the
|
||||
* task to be transferred to the worker and its `execute` function
|
||||
@ -730,27 +731,27 @@ public:
|
||||
* MyResult& result = task.result();
|
||||
* @endcode
|
||||
*/
|
||||
bool post(Task* pTask, Semaphore* pSem, enum execute_mode_t mode);
|
||||
bool execute(Task* pTask, Semaphore* pSem, enum execute_mode_t mode);
|
||||
|
||||
bool post(Task* pTask, enum execute_mode_t mode)
|
||||
bool execute(Task* pTask, enum execute_mode_t mode)
|
||||
{
|
||||
return post(pTask, NULL, mode);
|
||||
return execute(pTask, NULL, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts a task to a worker for execution.
|
||||
* Executes a task on the worker thread.
|
||||
*
|
||||
* @param pTask The task to be executed.
|
||||
* @param mode Execution mode
|
||||
*
|
||||
* @return True if the task could be posted (i.e. not executed), false otherwise.
|
||||
* @return True if the task could be posted (i.e. not executed yet), false otherwise.
|
||||
*
|
||||
* @attention Once the task has been executed, it will be deleted.
|
||||
*/
|
||||
bool post(std::unique_ptr<DisposableTask> sTask, enum execute_mode_t mode);
|
||||
bool execute(std::unique_ptr<DisposableTask> sTask, enum execute_mode_t mode);
|
||||
|
||||
/**
|
||||
* Execute a funcion in a worker
|
||||
* Execute a function on the worker thread.
|
||||
*
|
||||
* @param func The function to call
|
||||
* @param pSem If non-NULL, will be posted once the task's `execute` return.
|
||||
@ -758,18 +759,16 @@ public:
|
||||
*
|
||||
* @return True, if task was posted to the worker
|
||||
*/
|
||||
bool post(GenericFunction func, Semaphore* pSem, enum execute_mode_t mode);
|
||||
bool execute(GenericFunction func, Semaphore* pSem, enum execute_mode_t mode);
|
||||
|
||||
/**
|
||||
* Execute function on worker
|
||||
*
|
||||
* This is a convenience wrapper of `post` with automatic waiting on the
|
||||
* semaphore.
|
||||
* Execute function on worker thread and return only when it has
|
||||
* been executed.
|
||||
*
|
||||
* @param func Function to execute
|
||||
* @param mode Execution mode
|
||||
*
|
||||
* @return True if function was executed on the worker
|
||||
* @return True if function was executed on the worker.
|
||||
*/
|
||||
bool call(GenericFunction func, enum execute_mode_t mode);
|
||||
|
||||
|
@ -3309,7 +3309,7 @@ static void poll_add_event_to_dcb(DCB* dcb, GWBUF* buf, uint32_t ev)
|
||||
if (task)
|
||||
{
|
||||
RoutingWorker* worker = static_cast<RoutingWorker*>(dcb->poll.owner);
|
||||
worker->post(std::unique_ptr<FakeEventTask>(task), mxs::Worker::EXECUTE_QUEUED);
|
||||
worker->execute(std::unique_ptr<FakeEventTask>(task), mxs::Worker::EXECUTE_QUEUED);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3523,7 +3523,7 @@ static bool dcb_add_to_worker(Worker* worker, DCB* dcb, uint32_t events)
|
||||
Worker* worker = static_cast<RoutingWorker*>(dcb->poll.owner);
|
||||
ss_dassert(worker);
|
||||
|
||||
if (worker->post(std::unique_ptr<AddDcbToWorker>(task), mxs::Worker::EXECUTE_QUEUED))
|
||||
if (worker->execute(std::unique_ptr<AddDcbToWorker>(task), mxs::Worker::EXECUTE_QUEUED))
|
||||
{
|
||||
rv = true;
|
||||
}
|
||||
|
@ -1280,7 +1280,7 @@ HttpResponse resource_handle_request(const HttpRequest& request)
|
||||
mxs::Semaphore sem;
|
||||
ResourceTask task(request);
|
||||
|
||||
worker->post(&task, &sem, mxs::Worker::EXECUTE_AUTO);
|
||||
worker->execute(&task, &sem, mxs::Worker::EXECUTE_AUTO);
|
||||
sem.wait();
|
||||
|
||||
return task.result();
|
||||
|
@ -604,7 +604,7 @@ size_t RoutingWorker::broadcast(Task* pTask, Semaphore* pSem)
|
||||
Worker* pWorker = this_unit.ppWorkers[i];
|
||||
ss_dassert(pWorker);
|
||||
|
||||
if (pWorker->post(pTask, pSem, EXECUTE_AUTO))
|
||||
if (pWorker->execute(pTask, pSem, EXECUTE_AUTO))
|
||||
{
|
||||
++n;
|
||||
}
|
||||
@ -650,7 +650,7 @@ size_t RoutingWorker::execute_serially(Task& task)
|
||||
RoutingWorker* pWorker = this_unit.ppWorkers[i];
|
||||
ss_dassert(pWorker);
|
||||
|
||||
if (pWorker->post(&task, &sem, EXECUTE_AUTO))
|
||||
if (pWorker->execute(&task, &sem, EXECUTE_AUTO))
|
||||
{
|
||||
sem.wait();
|
||||
++n;
|
||||
@ -894,7 +894,7 @@ bool RoutingWorker::get_qc_stats(int id, QC_CACHE_STATS* pStats)
|
||||
{
|
||||
Semaphore sem;
|
||||
Task task(pStats);
|
||||
pWorker->post(&task, &sem, EXECUTE_AUTO);
|
||||
pWorker->execute(&task, &sem, EXECUTE_AUTO);
|
||||
sem.wait();
|
||||
}
|
||||
|
||||
@ -1205,7 +1205,7 @@ json_t* mxs_rworker_to_json(const char* zHost, int id)
|
||||
WorkerInfoTask task(zHost, id + 1);
|
||||
mxs::Semaphore sem;
|
||||
|
||||
target->post(&task, &sem, mxs::Worker::EXECUTE_AUTO);
|
||||
target->execute(&task, &sem, mxs::Worker::EXECUTE_AUTO);
|
||||
sem.wait();
|
||||
|
||||
return task.resource(id);
|
||||
|
@ -359,8 +359,8 @@ static void session_free(MXS_SESSION *session)
|
||||
{
|
||||
// Destroy the service in the main routing worker thread
|
||||
mxs::RoutingWorker* main_worker = mxs::RoutingWorker::get(mxs::RoutingWorker::MAIN);
|
||||
main_worker->post(std::unique_ptr<ServiceDestroyTask>(new ServiceDestroyTask(service)),
|
||||
mxs::Worker::EXECUTE_AUTO);
|
||||
main_worker->execute(std::unique_ptr<ServiceDestroyTask>(new ServiceDestroyTask(service)),
|
||||
mxs::Worker::EXECUTE_AUTO);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ Worker* Worker::get_current()
|
||||
return this_thread.pCurrent_worker;
|
||||
}
|
||||
|
||||
bool Worker::post(Task* pTask, Semaphore* pSem, enum execute_mode_t mode)
|
||||
bool Worker::execute(Task* pTask, Semaphore* pSem, enum execute_mode_t mode)
|
||||
{
|
||||
// No logging here, function must be signal safe.
|
||||
bool rval = true;
|
||||
@ -444,7 +444,7 @@ bool Worker::post(Task* pTask, Semaphore* pSem, enum execute_mode_t mode)
|
||||
return rval;
|
||||
}
|
||||
|
||||
bool Worker::post(std::unique_ptr<DisposableTask> sTask, enum execute_mode_t mode)
|
||||
bool Worker::execute(std::unique_ptr<DisposableTask> sTask, enum execute_mode_t mode)
|
||||
{
|
||||
// No logging here, function must be signal safe.
|
||||
return post_disposable(sTask.release(), mode);
|
||||
@ -477,7 +477,7 @@ bool Worker::post_disposable(DisposableTask* pTask, enum execute_mode_t mode)
|
||||
return posted;
|
||||
}
|
||||
|
||||
bool Worker::post(GenericFunction func, Semaphore* pSem, execute_mode_t mode)
|
||||
bool Worker::execute(GenericFunction func, Semaphore* pSem, execute_mode_t mode)
|
||||
{
|
||||
|
||||
class CustomTask : public maxscale::WorkerTask
|
||||
@ -506,7 +506,7 @@ bool Worker::post(GenericFunction func, Semaphore* pSem, execute_mode_t mode)
|
||||
|
||||
if (task)
|
||||
{
|
||||
if (!(rval = post(task, pSem, mode)))
|
||||
if (!(rval = execute(task, pSem, mode)))
|
||||
{
|
||||
// Posting the task failed, it needs to be deleted now
|
||||
delete task;
|
||||
@ -519,7 +519,7 @@ bool Worker::post(GenericFunction func, Semaphore* pSem, execute_mode_t mode)
|
||||
bool Worker::call(GenericFunction func, execute_mode_t mode)
|
||||
{
|
||||
Semaphore sem;
|
||||
return post(func, &sem, mode) && sem.wait();
|
||||
return execute(func, &sem, mode) && sem.wait();
|
||||
}
|
||||
|
||||
bool Worker::post_message(uint32_t msg_id, intptr_t arg1, intptr_t arg2)
|
||||
|
@ -966,7 +966,7 @@ void MariaDBMonitor::disable_setting(const std::string& setting)
|
||||
{
|
||||
Worker* worker = static_cast<Worker*>(mxs_rworker_get(MXS_RWORKER_MAIN));
|
||||
|
||||
worker->post([=]()
|
||||
worker->execute([=]()
|
||||
{
|
||||
MXS_CONFIG_PARAMETER p = {};
|
||||
p.name = const_cast<char*>(setting.c_str());
|
||||
|
@ -335,7 +335,7 @@ static bool conversion_task_ctl(Avro *inst, bool start)
|
||||
|
||||
if (task.get())
|
||||
{
|
||||
worker->post(std::move(task), Worker::EXECUTE_AUTO);
|
||||
worker->execute(std::move(task), Worker::EXECUTE_AUTO);
|
||||
rval = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user