mirror of
https://github.com/NixOS/nix
synced 2025-07-05 12:21:48 +02:00
add isInterrupted() call and replace some checkInterrupt() occurrences
This commit is contained in:
parent
db297d3dda
commit
49f757c24a
4 changed files with 24 additions and 18 deletions
|
@ -26,6 +26,11 @@ static inline bool getInterrupted();
|
|||
*/
|
||||
void setInterruptThrown();
|
||||
|
||||
/**
|
||||
* @note Does nothing on Windows
|
||||
*/
|
||||
static inline bool isInterrupted();
|
||||
|
||||
/**
|
||||
* @note Does nothing on Windows
|
||||
*/
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,12 @@ inline void setInterruptThrown()
|
|||
/* Do nothing for now */
|
||||
}
|
||||
|
||||
void inline checkInterrupt()
|
||||
static inline bool isInterrupted()
|
||||
{
|
||||
/* Do nothing for now */
|
||||
}
|
||||
|
||||
inline void checkInterrupt()
|
||||
{
|
||||
/* Do nothing for now */
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue