File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
src/libutil/include/nix/util Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -447,18 +447,27 @@ struct LengthSource : Source
447447 */
448448struct LambdaSink : Sink
449449{
450- typedef std::function<void (std::string_view data)> lambda_t ;
450+ typedef std::function<void (std::string_view data)> data_t ;
451+ typedef std::function<void ()> cleanup_t ;
451452
452- lambda_t lambda;
453+ data_t dataFun;
454+ cleanup_t cleanupFun;
453455
454- LambdaSink (const lambda_t & lambda)
455- : lambda(lambda)
456+ LambdaSink (
457+ const data_t & dataFun, const cleanup_t & cleanupFun = []() {})
458+ : dataFun(dataFun)
459+ , cleanupFun(cleanupFun)
460+ {
461+ }
462+
463+ ~LambdaSink ()
456464 {
465+ cleanupFun ();
457466 }
458467
459468 void operator ()(std::string_view data) override
460469 {
461- lambda (data);
470+ dataFun (data);
462471 }
463472};
464473
You can’t perform that action at this time.
0 commit comments