Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
async-collect.hh File Reference
#include "lix/libutil/result.hh"
#include <concepts>
#include <kj/async.h>
#include <kj/common.h>
#include <kj/vector.h>
#include <list>
#include <optional>
#include <type_traits>

Go to the source code of this file.

Classes

class  nix::AsyncCollect< K, V >

Functions

template<typename K, typename V>
AsyncCollect< K, V > nix::asyncCollect (kj::Array< std::pair< K, kj::Promise< V > > > promises)
template<typename Input, typename Fn>
requires requires { { fn(*begin(input)) } -> std::same_as<kj::Promise<Result<void>>>; }
kj::Promise< Result< void > > nix::asyncSpread (Input &&input, Fn fn)

Function Documentation

◆ asyncCollect()

template<typename K, typename V>
AsyncCollect< K, V > nix::asyncCollect ( kj::Array< std::pair< K, kj::Promise< V > > > promises)

Collect the results of a list of promises, in order of completion. Once any input promise is rejected all promises that have not been resolved or rejected will be cancelled and the exception rethrown.

◆ asyncSpread()

template<typename Input, typename Fn>
requires requires { { fn(*begin(input)) } -> std::same_as<kj::Promise<Result<void>>>; }
kj::Promise< Result< void > > nix::asyncSpread ( Input && input,
Fn fn )

Run fn for every item in the input range asynchronously, using the same fail-fast semantics as asyncCollect. asyncSpread is a shorthand for calling asyncCollect with std::tuple() values as keys, awaiting that to completion, and propagating all exceptions.