1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 08:31:16 +02:00

Always disable GC in a coroutine unless the patch is applied

This commit is contained in:
Yorick van Pelt 2023-03-01 15:07:00 +01:00 committed by Théophane Hufschmitt
parent 00bc34430b
commit 58d24a4cb6
4 changed files with 28 additions and 11 deletions

View file

@ -186,18 +186,17 @@ static DefaultStackAllocator defaultAllocatorSingleton;
StackAllocator *StackAllocator::defaultAllocator = &defaultAllocatorSingleton;
std::shared_ptr<void> (*create_disable_gc)() = []() -> std::shared_ptr<void> {
std::shared_ptr<void> (*create_coro_gc_hook)() = []() -> std::shared_ptr<void> {
return {};
};
/* This class is used for entry and exit hooks on coroutines */
class CoroutineContext {
#if __APPLE__
/* Disable GC when entering the coroutine on macOS, since it doesn't find the main thread stack in this case.
/* Disable GC when entering the coroutine without the boehm patch,
* since it doesn't find the main thread stack in this case.
* std::shared_ptr<void> performs type-erasure, so it will call the right
* deleter. */
const std::shared_ptr<void> disable_gc = create_disable_gc();
#endif
const std::shared_ptr<void> coro_gc_hook = create_coro_gc_hook();
public:
CoroutineContext() {};
~CoroutineContext() {};