1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-17 07:52:43 +01:00

add isInterrupted() call and replace some checkInterrupt() occurrences

(cherry picked from commit 49f757c24a)
This commit is contained in:
Philipp Otterbein 2025-04-11 22:34:15 +02:00 committed by Mergify
parent c53bd8905b
commit 61bb405839
4 changed files with 24 additions and 18 deletions

View file

@ -85,17 +85,22 @@ static inline bool getInterrupted()
return unix::_isInterrupted;
}
static inline bool isInterrupted()
{
using namespace unix;
return _isInterrupted || (interruptCheck && interruptCheck());
}
/**
* Throw `Interrupted` exception if the process has been interrupted.
*
* Call this in long-running loops and between slow operations to terminate
* them as needed.
*/
void inline checkInterrupt()
inline void checkInterrupt()
{
using namespace unix;
if (_isInterrupted || (interruptCheck && interruptCheck()))
_interrupted();
if (isInterrupted())
unix::_interrupted();
}
/**