@@ -26,58 +26,15 @@ namespace execution_config_helper {
2626using task_priority = enqueue_priority;
2727
2828// / Parameters of a queue of tasks.
29- using task_queue = concurrent_queue_params;
30-
31- // / Parameters of a strand executor.
32- struct strand {
33- struct executor {
34- // / \brief Name of the strand executor.
35- std::string name;
36- // / \brief Queueing policy associated with this strand executor.
37- concurrent_queue_policy policy;
38- // / \brief Size of the queue used.
39- unsigned size;
40- // / \brief Whether the caller blocks waiting for task to complete.
41- bool synchronous = false ;
42- };
43- // / Queues of different priorities. The lower the index, the higher the priority.
44- std::vector<executor> queues;
45- };
46-
47- // / Parameters of the task executor, including name and decorators.
48- struct executor {
49- // / Name of the executor.
29+ struct task_queue {
30+ // / Name attributed to this task queue.
5031 std::string name;
51- // / Priority assigned to the tasks dispatched through this executor.
52- task_priority priority = task_priority::min;
53- // / Strands instantiated on top of this executor.
54- std::vector<strand> strands;
55- // / \brief Present if the executor works as a strand, serializing all the enqueued tasks. The value is the size of
56- // / the strand queue size.
57- std::optional<unsigned > strand_queue_size;
58- // / \brief Whether to make an executor synchronous. If true, the executor will be blocking, until the pushed task is
59- // / fully executed. This will have a negative impact on performance, but can be useful for debugging.
60- bool synchronous = false ;
61-
62- executor (const std::string& name_,
63- const std::vector<strand>& strands_ = {},
64- std::optional<unsigned > strand_queue_size_ = std::nullopt ,
65- bool synchronous_ = false ) :
66- name (name_), strands(strands_), strand_queue_size(strand_queue_size_), synchronous(synchronous_)
67- {
68- }
69- executor (const std::string& name_,
70- task_priority priority_,
71- const std::vector<strand>& strands_ = {},
72- std::optional<unsigned > strand_queue_size_ = std::nullopt ,
73- bool synchronous_ = false ) :
74- name (name_),
75- priority (priority_),
76- strands (strands_),
77- strand_queue_size (strand_queue_size_),
78- synchronous (synchronous_)
79- {
80- }
32+ // / Queueing policy used by this task queue.
33+ concurrent_queue_policy policy;
34+ // / Size of the queue used.
35+ unsigned size;
36+ // / Number of pre-reserved producers in the case of the moodycamel lockfree MPMC queue.
37+ unsigned nof_prereserved_producers = 2 ;
8138};
8239
8340// / Arguments for a single task worker creation.
@@ -86,17 +43,13 @@ struct single_worker {
8643 std::string name;
8744 // / Queue used by the task worker.
8845 task_queue queue;
89- // / Executors associated with this execution context.
90- std::vector<executor> executors;
9146 // / \brief Wait time in microseconds, when task queue has no pending tasks. If not set, a condition variable is
9247 // / used to wake up the worker when a new task is pushed.
9348 std::optional<std::chrono::microseconds> wait_sleep_time;
9449 // / OS priority of the worker thread.
9550 os_thread_realtime_priority prio = os_thread_realtime_priority::no_realtime();
9651 // / Bit mask to set worker cpu affinity.
9752 os_sched_affinity_bitmask mask = {};
98- // / Non null in case tracing of the worker executors is enabled.
99- file_event_tracer<true >* tracer = nullptr ;
10053};
10154
10255// / Arguments for a task worker pool creation.
@@ -107,16 +60,12 @@ struct worker_pool {
10760 unsigned nof_workers;
10861 // / Queue(s) used by the task worker. The lower the index, the higher the priority.
10962 std::vector<task_queue> queues;
110- // / Executors associated with this execution context.
111- std::vector<executor> executors;
11263 // / \brief Wait time in microseconds, when task queue has no pending tasks.
11364 std::chrono::microseconds sleep_time;
11465 // / OS priority of the worker thread.
11566 os_thread_realtime_priority prio = os_thread_realtime_priority::no_realtime();
11667 // / Array of CPU bitmasks to assign to each worker in the pool.
11768 std::vector<os_sched_affinity_bitmask> masks;
118- // / Non null in case tracing of the worker executors is enabled.
119- file_event_tracer<true >* tracer = nullptr ;
12069};
12170
12271// / Arguments for the creation of a priority multiqueue worker.
@@ -128,14 +77,10 @@ struct priority_multiqueue_worker {
12877 std::vector<task_queue> queues;
12978 // / \brief Wait time in microseconds, when task queue has no pending tasks.
13079 std::chrono::microseconds spin_sleep_time;
131- // / Executors associated with this execution context.
132- std::vector<executor> executors;
13380 // / OS priority of the worker thread.
13481 os_thread_realtime_priority prio = os_thread_realtime_priority::no_realtime();
13582 // / Bit mask to set worker cpu affinity.
13683 os_sched_affinity_bitmask mask = {};
137- // / Non null in case tracing of the worker executors is enabled.
138- file_event_tracer<true >* tracer = nullptr ;
13984};
14085
14186} // namespace execution_config_helper
0 commit comments