mirror of
https://github.com/chriskohlhoff/asio.git
synced 2026-01-18 16:51:17 +01:00
Add config option to determine whether timerfd is used.
Add a new configuration option "reactor" / "use_timerfd" that is used by the epoll_reactor. When true (the default), the reactor uses a timerfd descriptor to manage timeouts. When false, the duration until the next timeout is computed and passed as a timeout to epoll_wait.
This commit is contained in:
@@ -43,7 +43,8 @@ epoll_reactor::epoll_reactor(asio::execution_context& ctx)
|
||||
config(ctx).get("reactor", "registration_locking_spin_count", 0)),
|
||||
interrupter_(),
|
||||
epoll_fd_(do_epoll_create()),
|
||||
timer_fd_(do_timerfd_create()),
|
||||
timer_fd_(config(ctx).get("reactor", "use_timerfd", true)
|
||||
? do_timerfd_create() : -1),
|
||||
shutdown_(false),
|
||||
io_locking_(config(ctx).get("reactor", "io_locking", true)),
|
||||
io_locking_spin_count_(
|
||||
@@ -109,9 +110,11 @@ void epoll_reactor::notify_fork(
|
||||
epoll_fd_ = do_epoll_create();
|
||||
|
||||
if (timer_fd_ != -1)
|
||||
{
|
||||
::close(timer_fd_);
|
||||
timer_fd_ = -1;
|
||||
timer_fd_ = do_timerfd_create();
|
||||
timer_fd_ = -1;
|
||||
timer_fd_ = do_timerfd_create();
|
||||
}
|
||||
|
||||
interrupter_.recreate();
|
||||
|
||||
|
||||
@@ -177,6 +177,19 @@ below.
|
||||
fails with `EAGAIN`.
|
||||
]
|
||||
]
|
||||
[
|
||||
[`reactor`]
|
||||
[`use_timerfd`]
|
||||
[`bool`]
|
||||
[`true`]
|
||||
[
|
||||
Linux [^epoll] backend only.
|
||||
|
||||
When `true`, the reactor uses a [^timerfd] descriptor to manage timeouts.
|
||||
When `false`, the duration until the next timeout is computed and passed
|
||||
as a timeout to [^epoll_wait].
|
||||
]
|
||||
]
|
||||
[
|
||||
[`timer`]
|
||||
[`heap_reserve`]
|
||||
|
||||
Reference in New Issue
Block a user