-
Notifications
You must be signed in to change notification settings - Fork 206
Open
Description
Suppose we have an async operation:
stdexec::sender auto tcp::socket::async_connect(endpoint);
Now we try to connect a batch of endpoints, and wait for all/any of them.
stdexec::sender auto task_1 = socket_1.async_connect("127.0.0.1:1");
stdexec::sender auto task_2 = socket_2.async_connect("127.0.0.1:2");
stdexec::sender auto task_3 = socket_3.async_connect("127.0.0.1:3");
/* ... */
stdexec::sender auto task_65535 = socket_65535.async_connect("127.0.0.1:65535");
stdexec::sync_wait(stdexec::when_all(task_1, task_2, task_3, /*...*/, task_65535));
The functions above are all senders instead of synchronous functions (that is, submit task and later callback). Although we can bulk
synchronous functions using stdexec::bulk(policy, shape, sync_func)
, I wonder: is there a function that we can stdexec::/*bulk_what*/(policy, shape, func_who_returns_sender)
? I tried hard to read the docs but sadly could not find it.
auto sockets = std::vector<tcp::socket>(65535);
stdexec::sync_wait(stdexec::/*let_bulk_or_some_name_else?*/(
stdexec::par,
65535,
[&] { return sockets[i].async_connect(std::format("127.0.0.1:{}", i); }
)
Thank you!
miwechner
Metadata
Metadata
Assignees
Labels
No labels