Question: add sender after run
Closed this issue · 1 comments
Hey,
i'm trying the sender API and wondered how to add senders after the work has been started.
E.g. take the following code:
grpc_runner = std::jthread{[this]() {
auto my_rpc1 = ...;
auto my_rpc2 = ...;
grpc_context.work_started();
auto snd = exec::finally(stdexec::when_all(my_rpc1, my_rcp2),
stdexec::then(stdexec::just(), [this] { grpc_context.work_finished(); }));
stdexec::sync_wait(stdexec::when_all(snd, stdexec::then(stdexec::just(), [&] { grpc_context.run(); })));
}};
This works quite nice. (Thanks for that!)
However, I'm not quite sure on how to use a dynamic set of clients.
Previously I've just used the grpc_context and asio_context and added a new stub.
But now I've to somehow populate the sync_wait with the dynamic set of senders.
Do you have any tips on how to do that?
ah, I was a bit fast opening this question.
After implementing a bit more business logic it works like a charm.
For the client side logic the stubs will be created like the asio case and the senders will be created but will be returned as a exec task to be either awaitable or be used as a sender.
Sorry!