Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
PriorityQueue.h
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * PB, Patrick Bos, Netherlands eScience Center, p.bos@esciencecenter.nl
5 * IP, Inti Pelupessy, Netherlands eScience Center, i.pelupessy@esciencecenter.nl
6 *
7 * Copyright (c) 2022, CERN
8 *
9 * Redistribution and use in source and binary forms,
10 * with or without modification, are permitted according to the terms
11 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
12 */
13#ifndef ROOT_ROOFIT_MultiProcess_ReorderQueue
14#define ROOT_ROOFIT_MultiProcess_ReorderQueue
15
17#include <queue>
18
19namespace RooFit {
20namespace MultiProcess {
21
23 OrderedJobTask(JobTask job_task, std::size_t task_priority): jobTask(job_task), taskPriority(task_priority) {}
25 std::size_t taskPriority;
26
27 bool operator < (const OrderedJobTask& rhs) const {return taskPriority < rhs.taskPriority;}
28};
29
30class PriorityQueue : public Queue {
31public:
32 bool pop(JobTask &job_task) override;
33 void add(JobTask job_task) override;
34 void suggestTaskOrder(std::size_t job_id, const std::vector<Task>& task_order);
35 void setTaskPriorities(std::size_t job_id, const std::vector<std::size_t>& task_priorities);
36private:
37 std::priority_queue<OrderedJobTask> queue_;
38 // key: job ID, value: task priority; higher value means higher priority
39 std::unordered_map<std::size_t, std::vector<std::size_t>> task_priority_;
40};
41
42} // namespace MultiProcess
43} // namespace RooFit
44
45#endif // ROOT_ROOFIT_MultiProcess_ReorderQueue
Queue that orders tasks according to specified task priorities.
void setTaskPriorities(std::size_t job_id, const std::vector< std::size_t > &task_priorities)
Set the priority for Job tasks.
void add(JobTask job_task) override
See Queue::add.
void suggestTaskOrder(std::size_t job_id, const std::vector< Task > &task_order)
Set the desired order for executing tasks of a Job.
std::unordered_map< std::size_t, std::vector< std::size_t > > task_priority_
std::priority_queue< OrderedJobTask > queue_
bool pop(JobTask &job_task) override
See Queue::pop.
Keeps a queue of tasks for workers and manages the queue process through its event loop.
Definition Queue.h:22
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26
combined job_object, state and task identifier type
Definition types.h:25
OrderedJobTask(JobTask job_task, std::size_t task_priority)
bool operator<(const OrderedJobTask &rhs) const