diff options
author | eldritch horrors <pennae@lix.systems> | 2024-10-05 00:38:35 +0200 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-10-05 19:06:59 +0000 |
commit | 99edc2ae38b533ecd742c172a3531cc8958c4be5 (patch) | |
tree | 6e3753a83bab6981ddf76fabc17e2bacff7452b9 /src/libutil/signals.cc | |
parent | 896a123605b825cd0a1548fc40da1a757ca30d25 (diff) |
libstore: check for interrupts in parallel promise
this simplifies the worker loop, and lets us remove it entirely later.
note that ideally only one promise waiting for interrupts should exist
in the entire system. not one per event loop, one per *process*. extra
interrupt waiters make interrupt response nondeterministic and as such
aren't great for user experience. if anything wants to react to aborts
caused by explicit interruptions, or anything else, those things would
be much better served using RAII guards such as Finally (or KJ_DEFER).
Change-Id: I41d035ff40172d536e098153c7375b0972110d51
Diffstat (limited to 'src/libutil/signals.cc')
-rw-r--r-- | src/libutil/signals.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libutil/signals.cc b/src/libutil/signals.cc index 4e9ed0ba1..dac2964ae 100644 --- a/src/libutil/signals.cc +++ b/src/libutil/signals.cc @@ -12,13 +12,18 @@ std::atomic<bool> _isInterrupted = false; thread_local std::function<bool()> interruptCheck; +Interrupted makeInterrupted() +{ + return Interrupted("interrupted by the user"); +} + void _interrupted() { /* Block user interrupts while an exception is being handled. Throwing an exception while another exception is being handled kills the program! */ if (!std::uncaught_exceptions()) { - throw Interrupted("interrupted by the user"); + throw makeInterrupted(); } } |