35 else if (!tq.empty()) {
37 if ((now.mono_time() - tq.front().expiry()) > 100
ms) {
54 epoll_.
del(notify_.
fd());
61 if (fd >=
static_cast<int>(data_.size())) {
64 auto&
ref = data_[fd];
65 epoll_.
add(fd, ++
ref.sid, events);
69 return {*
this, fd,
ref.sid};
75 using namespace chrono;
99 now = CyclTime::now();
100 last_time_priority_io_polled_ = now.
wall_time();
104 throw system_error{
ec};
111 cycle_work_ = tqs_[
High].dispatch(now);
118 if (cycle_work_ > 0) {
135 using namespace chrono;
137 const auto& tq = tqs_[
High];
141 next =
min(next, tq.front().expiry() - 200u
s);
145 const auto& tq = tqs_[
Low];
148 next =
min(next, tq.front().expiry());
156 if (currently_handling_priority_events_) [[
unlikely]] {
160 if (priority_io_poll_threshold == Micros::max()) {
165 if (now - last_time_priority_io_polled_ > priority_io_poll_threshold) {
166 last_time_priority_io_polled_ = now;
174 throw system_error{
ec};
186 assert(!currently_handling_priority_events_);
187 currently_handling_priority_events_ =
true;
190 currently_handling_priority_events_ =
false;
194 for (
int i{0};
i <
size; ++
i) {
197 const auto fd = epoll_.
fd(
ev);
198 const auto&
ref = data_[fd];
200 if (
ref.priority != priority) {
204 if (fd == notify_.
fd()) {
214 const auto sid = epoll_.
sid(
ev);
229 ref.slot(now, fd, events);
230 }
catch (
const std::exception& e) {
231 TOOLBOX_ERROR <<
"exception in i/o event handler: " << e.what();
238void Reactor::set_events(
int fd,
int sid,
unsigned events,
IoSlot slot, error_code&
ec)
noexcept
240 auto&
ref = data_[fd];
241 if (
ref.sid == sid) {
242 if (
ref.events != events) {
243 epoll_.mod(fd, sid, events,
ec);
248 high_prio_epoll_.mod(fd, sid, events);
256void Reactor::set_events(
int fd,
int sid,
unsigned events,
IoSlot slot)
258 auto&
ref = data_[fd];
259 if (
ref.sid == sid) {
260 if (
ref.events != events) {
261 epoll_.
mod(fd, sid, events);
263 high_prio_epoll_.
mod(fd, sid, events);
271void Reactor::set_events(
int fd,
int sid,
unsigned events, error_code&
ec)
noexcept
273 auto&
ref = data_[fd];
274 if (
ref.sid == sid &&
ref.events != events) {
275 epoll_.mod(fd, sid, events,
ec);
280 high_prio_epoll_.mod(fd, sid, events);
286void Reactor::set_events(
int fd,
int sid,
unsigned events)
288 auto&
ref = data_[fd];
289 if (
ref.sid == sid &&
ref.events != events) {
290 epoll_.
mod(fd, sid, events);
293 high_prio_epoll_.
mod(fd, sid, events);
298void Reactor::unsubscribe(
int fd,
int sid)
noexcept
300 auto&
ref = data_[fd];
301 if (
ref.sid == sid) {
303 high_prio_epoll_.del(fd);
312void Reactor::set_io_priority(
int fd,
int sid,
Priority priority)
noexcept
314 auto&
ref = data_[fd];
315 if (
ref.sid == sid &&
ref.priority != priority) {
317 high_prio_epoll_.add(fd, sid,
ref.events);
319 high_prio_epoll_.del(fd);
321 ref.priority = priority;
#define TOOLBOX_PROBE_SCOPED(provider, name,...)