Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README-RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ path, который запрашивает stop.
долгий блокирующий `process()` может отложить обработку SIGINT/SIGTERM до
возврата управления в runner loop.

Для POSIX-приложений с длинными throttle delays добавьте opt-in self-pipe
component до компонентов, которые могут блокировать loop:
Для POSIX-приложений с длинными задержками throttle добавьте опциональный
компонент self-pipe wake до компонентов, которые могут блокировать цикл:

```cpp
consolix::add<consolix::PosixSignalWakeComponent>();
Expand All @@ -252,10 +252,10 @@ consolix::add<consolix::LoopThrottleComponent>(
std::chrono::seconds(10));
```

POSIX handler по-прежнему только сохраняет сигнал и пишет один байт в pipe.
Watcher thread будит `LoopWakeService` уже из обычного C++ кода, поэтому
POSIX-обработчик по-прежнему только сохраняет сигнал и пишет один байт в pipe.
Поток-наблюдатель будит `LoopWakeService` уже из обычного C++-кода, поэтому
SIGINT/SIGTERM может прервать ожидание `LoopThrottleComponent` без mutex/CV
работы внутри signal handler. На Windows этот component является no-op.
работы внутри signal handler. На Windows этот компонент является no-op.

## Documentation

Expand Down
7 changes: 5 additions & 2 deletions include/consolix/components/PosixSignalWakeComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ namespace consolix {

private:
void stop_service() {
if (m_service) {
m_service->stop();
auto service = m_service;
m_service.reset();

if (service) {
service->stop();
}
m_initialized.store(false);
}
Expand Down
3 changes: 3 additions & 0 deletions include/consolix/core/PosixSignalWakeService.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ namespace consolix {
}

static volatile std::sig_atomic_t& signal_wake_fd() {
// Store the pipe fd as sig_atomic_t so the signal handler can read it
// without locks or C++ runtime calls. On supported POSIX targets,
// process-local file descriptors fit in this value.
static volatile std::sig_atomic_t fd = -1;
return fd;
}
Expand Down
Loading