diff options
author | Yorick van Pelt <yorick@yorickvanpelt.nl> | 2023-02-10 15:04:17 +0100 |
---|---|---|
committer | Théophane Hufschmitt <theophane.hufschmitt@tweag.io> | 2023-04-07 14:53:40 +0200 |
commit | 00bc34430b9e8e687cd3f1681e9f7b5baa7c717e (patch) | |
tree | e4631f9063041413967f9799793e9599a1b12341 /src/libexpr | |
parent | 2c53ef1bfee7c7afea889f42b9ef13e1007ad228 (diff) |
DisableGC: replace by CoroutineContext, std::shared_ptr<void>
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/eval.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index f7c056998..e5e8d2b22 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -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 |