However, this formulation forces the eager evaluation of the get_stop_token query, computing the stop-token which then needs to be curried and stored in the returned environment.
If we imagine many such algorithms using this formulation that are composed (e.g. multiple nested when_all() senders) then we can easily end up with the environment returned from the leaf operation's receiver could include many such stop-tokens, each copied into the final environment.
Instead, what I think we want to do is define an impls-for<Cpo>::query-env(query, state, parent_rcvr) operation rather than get-env. Then we change get_env implementation on basic-receiver to instead return a basic-env that holds a basic-operation* op_; member and then forwards queries to return impls-for<Cpo>::query-env(query, op_->state_, op_->rcvr_);
This would allow environment queries to be computed lazily instead of eagerly computing the values for environment queries.
The definition of impls-for<when_all_t>::query-env would then be:
The current wording of
[exec.when.all]
defines theimpls-for<when_all_t>::get-env
implementation as:However, this formulation forces the eager evaluation of the
get_stop_token
query, computing the stop-token which then needs to be curried and stored in the returned environment.If we imagine many such algorithms using this formulation that are composed (e.g. multiple nested when_all() senders) then we can easily end up with the environment returned from the leaf operation's receiver could include many such stop-tokens, each copied into the final environment.
Instead, what I think we want to do is define an
impls-for<Cpo>::query-env(query, state, parent_rcvr)
operation rather thanget-env
. Then we changeget_env
implementation onbasic-receiver
to instead return abasic-env
that holds abasic-operation* op_;
member and then forwards queries toreturn impls-for<Cpo>::query-env(query, op_->state_, op_->rcvr_);
This would allow environment queries to be computed lazily instead of eagerly computing the values for environment queries.
The definition of
impls-for<when_all_t>::query-env
would then be: