pika
pika copied to clipboard
Add throttler adaptor
Possible options:
// This can only throttle the full chain of senders up to and including
// myadaptor
sender_chain | myadaptor(f) | throttle(throttler) | ...;
// Should probably be spelled like this anyway to make it clear that it
// throttles the whole chain
throttle(sender_chain | myadaptor(f), throttler) | ...;
// This can only throttle the call of f, but not its completion if used e.g.
// with transform_mpi, unless specialized, but that scales badly
sender_chain | myadaptor(throttle(f)) | ...;
// This can throttle specifically myadaptor
sender_chain | throttle(throttler, [](auto&&... ts) { return ex::just(ts...) | myadaptor(f); }) | ...;
// The above could possibly be reformulated using let_value itself, but the lifetime of the throttler object would have to end when myadaptor completes (which it's not currently guaranteed to do)
sender_chain | something_to_send_a_throttler_object | let_value([](auto&... ts) { return ex::just(ts...) | myadaptor(f); }) | ...;
This is highly related to DLA-Future's tile access mechanism, pika's async_rw_mutex, and concore's serializers (https://concore.readthedocs.io/en/latest/concepts.html#serializers).