Skip to main content

gpu_stage

Function gpu_stage 

Source
pub fn gpu_stage<I, O, F, Fut>(
    source: Source<I>,
    parallelism: usize,
    f: F,
) -> Source<O>
where I: Send + 'static, O: Send + 'static, F: FnMut(I) -> Fut + Send + 'static, Fut: Future<Output = O> + Send + 'static,
Expand description

Apply an async GPU stage with the given degree of parallelism. Ordering is preserved (akka.net’s SelectAsync).

§Example

let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<f32>();
let s = source_from_unbounded(rx);
let s = gpu_stage::<f32, f32, _, _>(s, 4, |x| async move { x * 2.0 });
let out = Sink::collect(s).await;