1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 15:32:43 +01:00

refactor: RAII logger suspension

(cherry picked from commit 30694b5d8a)
This commit is contained in:
Robert Hensing 2025-03-04 19:10:33 +01:00 committed by Mergify
parent 375df6c086
commit ac3fc8876c
7 changed files with 46 additions and 35 deletions

View file

@ -4,6 +4,7 @@
#include "error.hh"
#include "config.hh"
#include "file-descriptor.hh"
#include "finally.hh"
#include <nlohmann/json_fwd.hpp>
@ -75,6 +76,17 @@ public:
virtual void stop() { };
/**
* Guard object to resume the logger when done.
*/
struct Suspension {
Finally<std::function<void()>> _finalize;
};
Suspension suspend();
std::optional<Suspension> suspendIf(bool cond);
virtual void pause() { };
virtual void resume() { };