1mod batch_fn;
2pub mod cached;
3pub mod non_cached;
4mod runtime;
5
6pub use batch_fn::BatchFn;
7
8use std::{future::Future, pin::Pin};
9
10pub trait WaitForWorkFn:
12 Fn() -> Pin<Box<dyn Future<Output = ()> + Send + Sync>> + Send + Sync + 'static
13{
14}
15
16impl<T> WaitForWorkFn for T where
17 T: Fn() -> Pin<Box<dyn Future<Output = ()> + Send + Sync>> + Send + Sync + 'static
18{
19}
20
21pub(crate) fn yield_fn(count: usize) -> impl WaitForWorkFn {
22 move || {
23 Box::pin(async move {
24 for _ in 0..count {
26 runtime::yield_now().await;
27 }
28 })
29 }
30}