Keeps a queue of tasks for workers and manages the queue process through its event loop.
The Queue maintains a set of tasks on the queue process by receiving them from the master process. Worker processes can request to pop them off the queue. The communication between these processes is handled inside 'Queue::loop()', the queue process's event loop that polls the Messenger's sockets for incoming messages and handles them when they come.
The reason for this class is to get automatic load balancing between workers. By allowing workers to request tasks whenever they are ready to do work, we don't need to manually distribute work over workers and they will always have something to do until all tasks have been completed. The alternative simple strategy of just distributing all tasks evenly over workers will be suboptimal when tasks have different or even varying runtimes (this simple strategy could be implemented with a PUSH-PULL ZeroMQ socket from master to workers, which would distribute tasks in a round-robin fashion, which, indeed, does not do load balancing).
Public Member Functions | |
virtual | ~Queue ()=default |
virtual void | add (JobTask job_task)=0 |
Enqueue a task. | |
void | loop () |
The queue process's event loop. | |
virtual bool | pop (JobTask &job_task)=0 |
Have a worker ask for a task-message from the queue. | |
void | process_master_message (M2Q message) |
Helper function for 'Queue::loop()'. | |
void | process_worker_message (std::size_t this_worker_id, W2Q message) |
Helper function for 'Queue::loop()'. | |
Protected Attributes | |
std::size_t | N_tasks_ = 0 |
std::size_t | N_tasks_at_workers_ = 0 |
|
virtualdefault |
|
pure virtual |
Enqueue a task.
Implemented in RooFit::MultiProcess::FIFOQueue, and RooFit::MultiProcess::PriorityQueue.
void RooFit::MultiProcess::Queue::loop | ( | ) |
Have a worker ask for a task-message from the queue.
Implemented in RooFit::MultiProcess::FIFOQueue, and RooFit::MultiProcess::PriorityQueue.
void RooFit::MultiProcess::Queue::process_master_message | ( | M2Q | message | ) |
Helper function for 'Queue::loop()'.
void RooFit::MultiProcess::Queue::process_worker_message | ( | std::size_t | this_worker_id, |
W2Q | message | ||
) |
Helper function for 'Queue::loop()'.
|
protected |
|
protected |