Function forest_filecoin::utils::stream::par_buffer

source ยท
pub fn par_buffer<V: Send + Sync + 'static>(
    cap: usize,
    stream: impl Stream<Item = V> + Send + Sync + 'static,
) -> impl Stream<Item = V>
Expand description

Decouple stream generation and stream consumption into separate threads, keeping not-yet-consumed elements in a bounded queue. This is similar to stream::buffered and sink::buffer. The key difference is that par_buffer is parallel rather than concurrent and will make use of multiple cores when both the stream and the stream consumer are CPU-bound. Because a new thread is spawned, the stream has to be Sync, Send and 'static.