diff options
Diffstat (limited to 'src/libutil/serialise.cc')
-rw-r--r-- | src/libutil/serialise.cc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc index 3a8a01f16..80b111f08 100644 --- a/src/libutil/serialise.cc +++ b/src/libutil/serialise.cc @@ -266,20 +266,17 @@ std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun) } -std::unique_ptr<Source> sinkToSource( - std::function<void(Sink &)> fun, - std::function<void()> eof) +std::unique_ptr<Source> sinkToSource(std::function<void(Sink &)> fun) { struct SinkToSource : Source { typedef boost::coroutines2::coroutine<std::string> coro_t; std::function<void(Sink &)> fun; - std::function<void()> eof; std::optional<coro_t::pull_type> coro; - SinkToSource(std::function<void(Sink &)> fun, std::function<void()> eof) - : fun(fun), eof(eof) + SinkToSource(std::function<void(Sink &)> fun) + : fun(fun) { } @@ -298,7 +295,9 @@ std::unique_ptr<Source> sinkToSource( }); } - if (!*coro) { eof(); abort(); } + if (!*coro) { + throw EndOfFile("coroutine has finished"); + } if (pos == cur.size()) { if (!cur.empty()) { @@ -317,7 +316,7 @@ std::unique_ptr<Source> sinkToSource( } }; - return std::make_unique<SinkToSource>(fun, eof); + return std::make_unique<SinkToSource>(fun); } |