diff --git a/include/maxscale/routingworker.hh b/include/maxscale/routingworker.hh index 61b258482..688c0c45e 100644 --- a/include/maxscale/routingworker.hh +++ b/include/maxscale/routingworker.hh @@ -388,6 +388,7 @@ public: * otherwise the task is delivered via the message loop. */ static size_t execute_serially(Task& task); + static size_t execute_serially(std::function func); /** * Executes a task on all workers concurrently and waits until all workers diff --git a/server/core/routingworker.cc b/server/core/routingworker.cc index 11af2d5e2..dac4a2ac8 100644 --- a/server/core/routingworker.cc +++ b/server/core/routingworker.cc @@ -773,6 +773,28 @@ size_t RoutingWorker::execute_serially(Task& task) return n; } +//static +size_t RoutingWorker::execute_serially(std::function func) +{ + Semaphore sem; + size_t n = 0; + + int nWorkers = this_unit.next_worker_id; + for (int i = 0; i < nWorkers; ++i) + { + RoutingWorker* pWorker = this_unit.ppWorkers[i]; + mxb_assert(pWorker); + + if (pWorker->execute(func, &sem, EXECUTE_AUTO)) + { + sem.wait(); + ++n; + } + } + + return n; +} + // static size_t RoutingWorker::execute_concurrently(Task& task) {