From 4193c4d3dbf631436d1c5892b50b5d178a446b93 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 9 Aug 2018 15:21:01 +0300 Subject: [PATCH] MXS-2002 Add additional versions of Worker::[call|execute]() --- include/maxscale/worker.hh | 20 +++++++++++++++++-- server/core/worker.cc | 6 ++++++ .../modules/monitor/mariadbmon/mariadbmon.cc | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/maxscale/worker.hh b/include/maxscale/worker.hh index 9ca635c01..8d38625ca 100644 --- a/include/maxscale/worker.hh +++ b/include/maxscale/worker.hh @@ -761,9 +761,25 @@ public: */ bool execute(GenericFunction func, Semaphore* pSem, enum execute_mode_t mode); + bool execute(GenericFunction func, enum execute_mode_t mode) + { + return execute(func, NULL, mode); + } + /** - * Execute function on worker thread and return only when it has - * been executed. + * Executes a task on the worker thread and returns only when the task + * has finished. + * + * @param task The task to be executed. + * @param mode Execution mode + * + * @return True if the task was executed on the worker. + */ + bool call(Task& task, enum execute_mode_t mode); + + /** + * Executes function on worker thread and returns only when the function + * has finished. * * @param func Function to execute * @param mode Execution mode diff --git a/server/core/worker.cc b/server/core/worker.cc index c9673902c..d57f21a5c 100644 --- a/server/core/worker.cc +++ b/server/core/worker.cc @@ -516,6 +516,12 @@ bool Worker::execute(GenericFunction func, Semaphore* pSem, execute_mode_t mode) return rval; } +bool Worker::call(Task& task, execute_mode_t mode) +{ + Semaphore sem; + return execute(&task, &sem, mode) && sem.wait(); +} + bool Worker::call(GenericFunction func, execute_mode_t mode) { Semaphore sem; diff --git a/server/modules/monitor/mariadbmon/mariadbmon.cc b/server/modules/monitor/mariadbmon/mariadbmon.cc index ec99f26e7..63bdf66d6 100644 --- a/server/modules/monitor/mariadbmon/mariadbmon.cc +++ b/server/modules/monitor/mariadbmon/mariadbmon.cc @@ -972,7 +972,7 @@ void MariaDBMonitor::disable_setting(const std::string& setting) p.name = const_cast(setting.c_str()); p.value = const_cast("false"); monitor_add_parameters(m_monitor, &p); - }, NULL, EXECUTE_AUTO); + }, EXECUTE_AUTO); } /**