Closed barafael closed 2 days ago
It seems that unless recv_many
is optimized internally, the performance difference between providing this try_recv_many
and calling try_recv
in a loop will not be particularly large.
Please see:
thanks for clarifying!
Problem
I want to receive data from an mpsc within the sync world. I want to be able to receive multiple items if available for faster processing and less context switching.
Solution
mpsc::Receiver::try_recv bridges the async-sync gap. It would be great if it had a variant similar to async recv_many.
Alternatives
It would be possible to keep calling try_recv in a loop until it fails and push the data into a vector manually. This would at least incur the cost of possibly growing that vector.