Add tokio::sync::mpsc::UnboundedSender::send_many to improve the case of sending many values to an unbounded channel at once. #4643
Labels
A-tokio
Area: The main tokio crate
C-feature-request
Category: A feature request.
M-sync
Module: tokio/sync
Currently
mpsc::UnboundedSender
don't allow sending more than one value at once, so when sending multiple values this needs to be done manually by calling it multiple times.Wouldn't it be possible to add a method that takes an
Iterator
and performs the internal atomic operations to reserve space only once using thesize_hint
when available (at least if no new blocks need to be added and the size hint is reliable).Of course this would need to be careful because the
size_hint
may not be trustworthy.I'm not sure if that feature would make sense for bounded channels as well since the potentially empty slots from allocating to much in advance would reduce the channels capacity temporarily.
The text was updated successfully, but these errors were encountered: