13using GetEdgesAsync = std::function<void(
const T &, std::function<
void(std::promise<set<T>> &)>)>;
17 const set<T> startElts,
19 GetEdgesAsync<T> getEdgesAsync
26 std::exception_ptr exc;
29 Sync<State> state_(
State{0,
res, 0});
31 std::function<void(
const T &)> enqueue;
33 std::condition_variable done;
35 enqueue = [&](
const T & current) ->
void {
37 auto state(state_.lock());
38 if (state->exc)
return;
39 if (!state->res.insert(current).second)
return;
43 getEdgesAsync(current, [&](std::promise<set<T>> & prom) {
45 auto children = prom.get_future().get();
46 for (
auto & child : children)
49 auto state(state_.lock());
50 assert(state->pending);
51 if (!--state->pending) done.notify_one();
54 auto state(state_.lock());
55 if (!state->exc) state->exc = std::current_exception();
56 assert(state->pending);
57 if (!--state->pending) done.notify_one();
62 for (
auto & startElt : startElts)
66 auto state(state_.lock());
67 while (state->pending) state.wait(done);
68 if (state->exc) std::rethrow_exception(state->exc);
Strings res
Definition lexer.l:2566
virtual bool set(const std::string &name, const std::string &value)=0
Definition buildenv.cc:13