#include <dispatcher.h>
|
template<template< typename > typename kind_of, event_c event_t>
requires kind_c<kind_of> |
| void | queue_back (kind_of< event_t > ke) |
| |
template<template< typename > typename kind_of, event_c event_t>
requires kind_c<kind_of> |
| void | queue_front (kind_of< event_t > ke) |
| |
Definition at line 46 of file dispatcher.h.
◆ dispatcher()
| pars::ev::dispatcher::dispatcher |
( |
runner & | r | ) |
|
|
inline |
Definition at line 49 of file dispatcher.h.
50 : runner_m{r}
51 {
52 }
◆ queue_back()
template<template< typename > typename kind_of, event_c event_t>
requires kind_c<kind_of>
| void pars::ev::dispatcher::queue_back |
( |
kind_of< event_t > | ke | ) |
|
|
inline |
Definition at line 117 of file dispatcher.h.
118 {
119 auto guard = std::lock_guard{mtx_m};
120
121 queue(std::move(ke),
122 std::bind(std::mem_fn<void(decltype(queue_m)::value_type&&)>(
123 &decltype(queue_m)::push_back),
124 &queue_m, std::placeholders::_1));
125 }
Referenced by run().
◆ queue_front()
template<template< typename > typename kind_of, event_c event_t>
requires kind_c<kind_of>
| void pars::ev::dispatcher::queue_front |
( |
kind_of< event_t > | ke | ) |
|
|
inline |
Definition at line 129 of file dispatcher.h.
130 {
131 auto guard = std::lock_guard{mtx_m};
132
133 queue(std::move(ke),
134 std::bind(std::mem_fn<void(decltype(queue_m)::value_type&&)>(
135 &decltype(queue_m)::push_front),
136 &queue_m, std::placeholders::_1));
137 }
◆ run()
| void pars::ev::dispatcher::run |
( |
| ) |
|
|
inline |
Definition at line 56 of file dispatcher.h.
57 {
58 running_m = true;
59
61
62 for (;;)
63 {
64 auto lock = std::unique_lock{mtx_m};
65
66 cond_m.wait(lock, [&]() { return !queue_m.empty() || !running_m; });
67
68 if (!running_m)
69 {
70 cond_m.wait(lock, [&]() { return terminate_m; });
71
72 return;
73 }
74
75
76
77 runner_m.exec(next_job(lock));
78 }
79 }
void queue_back(kind_of< event_t > ke)
fired(event_t, metadata< fired, event_t >) -> fired< event_t >
References queue_back().
◆ stop_running()
| void pars::ev::dispatcher::stop_running |
( |
| ) |
|
|
inline |
Definition at line 81 of file dispatcher.h.
82 {
83 auto guard = std::lock_guard{mtx_m};
84
85 queue_m.clear();
86
87 runner_m.stop_all_threads();
88
89 running_m = false;
90
91 cond_m.notify_one();
92 }
◆ terminate_now()
| void pars::ev::dispatcher::terminate_now |
( |
| ) |
|
|
inline |
Definition at line 94 of file dispatcher.h.
95 {
96 auto guard = std::lock_guard{mtx_m};
97
98 if (running_m)
99 throw std::runtime_error("Call stop_running first!");
100
101 terminate_m = true;
102
103 cond_m.notify_one();
104 }
◆ terminating()
| bool pars::ev::dispatcher::terminating |
( |
| ) |
|
|
inline |
Definition at line 106 of file dispatcher.h.
107 {
108 auto guard = std::lock_guard{mtx_m};
109
110 return running_m == false;
111 }
The documentation for this class was generated from the following file:
- /home/runner/work/pars-cxx/pars-cxx/lib/include/pars/ev/dispatcher.h