1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 13:41:15 +02:00

sourceToSink(): Throw EndOfFile

This commit is contained in:
Eelco Dolstra 2024-07-22 15:18:58 +02:00
parent 0194f81587
commit 609df83c01
2 changed files with 4 additions and 6 deletions

View file

@ -246,9 +246,8 @@ std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun)
LambdaSource source([&](char * out, size_t out_len) {
if (cur.empty()) {
yield();
if (yield.get()) {
return (size_t) 0;
}
if (yield.get())
throw EndOfFile("coroutine has finished");
}
size_t n = std::min(cur.size(), out_len);
@ -271,12 +270,12 @@ std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun)
void finish() override
{
if (!coro) return;
//if (!*coro) abort();
if (!*coro) abort();
{
CoroutineContext ctx;
(*coro)(true);
}
//if (*coro) abort();
if (*coro) abort();
}
};