mirror of
https://github.com/NixOS/nix
synced 2025-06-28 05:21:16 +02:00
LocalStore::addToStoreFromDump copy in chunks
Rather than copying byte-by-byte, we let the coroutine know how much data we would like it to send back to us.
This commit is contained in:
parent
9de96ef7d4
commit
592851fb67
4 changed files with 40 additions and 22 deletions
|
@ -260,11 +260,20 @@ struct LambdaSource : Source
|
|||
/* Convert a function that feeds data into a Sink into a Source. The
|
||||
Source executes the function as a coroutine. */
|
||||
std::unique_ptr<Source> sinkToSource(
|
||||
std::function<void(Sink &)> fun,
|
||||
std::function<void(Sink &, size_t &)> fun,
|
||||
std::function<void()> eof = []() {
|
||||
throw EndOfFile("coroutine has finished");
|
||||
});
|
||||
|
||||
static inline std::unique_ptr<Source> sinkToSource(
|
||||
std::function<void(Sink &)> fun,
|
||||
std::function<void()> eof = []() {
|
||||
throw EndOfFile("coroutine has finished");
|
||||
})
|
||||
{
|
||||
return sinkToSource([fun](Sink & s, size_t & _) { fun(s); }, eof);
|
||||
}
|
||||
|
||||
|
||||
void writePadding(size_t len, Sink & sink);
|
||||
void writeString(const unsigned char * buf, size_t len, Sink & sink);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue