Add std::function overload to RoutingWorker::broadcast
This makes it easier to collect distributed results from multiple workers.
This commit is contained in:
@ -634,6 +634,27 @@ size_t RoutingWorker::broadcast(std::unique_ptr<DisposableTask> sTask)
|
||||
return n;
|
||||
}
|
||||
|
||||
//static
|
||||
size_t RoutingWorker::broadcast(std::function<void ()> func, mxb::Semaphore* pSem,
|
||||
mxb::Worker::execute_mode_t mode)
|
||||
{
|
||||
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, pSem, mode))
|
||||
{
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
//static
|
||||
size_t RoutingWorker::execute_serially(Task& task)
|
||||
{
|
||||
|
Reference in New Issue
Block a user