diff options
author | Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com> | 2023-03-08 20:47:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-08 20:47:52 +0100 |
commit | 39700c5cbeeb8005bfbe052ea79ababe46d7f072 (patch) | |
tree | beaa1f8b1f746ec0e9766617f0f9ff5be2631810 /src/libutil/serialise.cc | |
parent | e8415dc439704ee71b0a03b60bc5110bd3426314 (diff) |
Revert "Disable GC during coroutine execution + test"
Diffstat (limited to 'src/libutil/serialise.cc')
-rw-r--r-- | src/libutil/serialise.cc | 39 |
1 files changed, 5 insertions, 34 deletions
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc index 6e53239f5..7476e6f6c 100644 --- a/src/libutil/serialise.cc +++ b/src/libutil/serialise.cc @@ -186,22 +186,6 @@ static DefaultStackAllocator defaultAllocatorSingleton; StackAllocator *StackAllocator::defaultAllocator = &defaultAllocatorSingleton; -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 { - /* 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> coro_gc_hook = create_coro_gc_hook(); -public: - CoroutineContext() {}; - ~CoroutineContext() {}; -}; - std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun) { struct SourceToSink : FinishSink @@ -222,8 +206,7 @@ std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun) if (in.empty()) return; cur = in; - if (!coro) { - CoroutineContext ctx; + if (!coro) coro = coro_t::push_type(VirtualStackAllocator{}, [&](coro_t::pull_type & yield) { LambdaSource source([&](char *out, size_t out_len) { if (cur.empty()) { @@ -240,24 +223,17 @@ std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun) }); fun(source); }); - } if (!*coro) { abort(); } - if (!cur.empty()) { - CoroutineContext ctx; - (*coro)(false); - } + if (!cur.empty()) (*coro)(false); } void finish() override { if (!coro) return; if (!*coro) abort(); - { - CoroutineContext ctx; - (*coro)(true); - } + (*coro)(true); if (*coro) abort(); } }; @@ -288,23 +264,18 @@ std::unique_ptr<Source> sinkToSource( size_t read(char * data, size_t len) override { - if (!coro) { - CoroutineContext ctx; + if (!coro) coro = coro_t::pull_type(VirtualStackAllocator{}, [&](coro_t::push_type & yield) { LambdaSink sink([&](std::string_view data) { if (!data.empty()) yield(std::string(data)); }); fun(sink); }); - } if (!*coro) { eof(); abort(); } if (pos == cur.size()) { - if (!cur.empty()) { - CoroutineContext ctx; - (*coro)(); - } + if (!cur.empty()) (*coro)(); cur = coro->get(); pos = 0; } |