1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 23:11:16 +02:00

DisableGC: replace by CoroutineContext, std::shared_ptr<void>

This commit is contained in:
Yorick van Pelt 2023-02-10 15:04:17 +01:00 committed by Théophane Hufschmitt
parent 2c53ef1bfe
commit 00bc34430b
3 changed files with 34 additions and 34 deletions

View file

@ -344,20 +344,22 @@ static Symbol getName(const AttrName & name, EvalState & state, Env & env)
}
}
class BoehmDisableGC : public DisableGC {
#if HAVE_BOEHMGC
/* Disable GC while this object lives. Used by CoroutineContext.
*
* Boehm keeps a count of GC_disable() and GC_enable() calls,
* and only enables GC when the count matches.
*/
class BoehmDisableGC {
public:
BoehmDisableGC() {
#if HAVE_BOEHMGC
GC_disable();
#endif
};
virtual ~BoehmDisableGC() override {
#if HAVE_BOEHMGC
~BoehmDisableGC() {
GC_enable();
#endif
};
};
#endif
static bool gcInitialised = false;
@ -384,8 +386,8 @@ void initGC()
/* Used to disable GC when entering coroutines on macOS */
DisableGC::create = []() {
return std::dynamic_pointer_cast<DisableGC>(std::make_shared<BoehmDisableGC>());
create_disable_gc = []() -> std::shared_ptr<void> {
return std::make_shared<BoehmDisableGC>();
};
/* Set the initial heap size to something fairly big (25% of