pub fn delay_loading_batches<'a>() -> DelayGuard<'a> {
    with_batch_ctx(|ctx| {
        ctx.postpone_loading += 1;
    });
    DelayGuard(PhantomData)
}
/// Provides a guard which prevents loading new batches until dropped.
///
/// ```
/// # use async_dataloader::{*};
/// # use futures::FutureExt;
/// #
/// # futures::executor::block_on(async {
/// #
/// #
/// # async fn yield_now() {
/// #     struct YieldNow {
/// #         yielded: bool,
/// #     }
/// #
/// #     impl std::future::Future for YieldNow {
/// #         type Output = ();
/// #         fn poll(mut self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
/// #             if self.yielded {
/// #                 std::task::Poll::Ready(())
/// #             } else {
/// #                 cx.waker().wake_by_ref();
/// #                 self.yielded = true;
/// #                 std::task::Poll::Pending
/// #             }
/// #         }
/// #     }
/// #
/// #     YieldNow { yielded: false }.await;
/// # }
///
/// def_batch_loader! {
///     pub async fn loader(inputs: u64) -> (Vec<u64>, String) {
///         let inputs: Vec<_> = inputs.map(|a| *a).collect();
///         let inputs_copy = inputs.clone();
///
///         inputs.into_iter().map(move |input| {
///             (inputs_copy.clone(), input.to_string())
///         })
///     }
/// }
///
/// batched(async {
///     let mut one = loader(1);
///     let mut two = loader(2);
///     let mut three = loader(3);
///
///     one.schedule();
///
///     // yielding without delay_loading_batches will cause the batch to load
///     yield_now().await;
///
///     assert_eq!(one.await, Box::new((vec![1], "1".to_owned())));
///
///     // delay_loading_batches enables accumulating batches across yields
///     let guard = delay_loading_batches();
///     two.schedule();
///     yield_now().await;
///     drop(guard);
///
///     let three = three.await;
///
///     assert_eq!(three, Box::new((vec![2, 3], "3".to_owned())));
/// }).await;
/// # });
/// ```
/// ## Panics
///
/// Must be called from within a batched() context.
Provides a guard which prevents loading new batches until dropped.
Provides a guard which prevents loading new batches until dropped .
pub fn delay_loading_batches<'a>() -> DelayGuard<'a> {
    with_batch_ctx(|ctx| {
        ctx.postpone_loading += 1;
    });
    DelayGuard(PhantomData)
}
pub fn delay_loading_batches < ' a > ( ) -> DelayGuard < ' a > { with_batch_ctx ( | ctx | { ctx . postpone_loading += 1 ; } ) ; DelayGuard ( PhantomData ) }
Provides a guard which prevents loading new batches until dropped.
Provides a guard which prevents loading new batches until dropped .
use async_dataloader::{*};
None
use futures::futureext;
None
futures::executor::block_on(async {
None
async fn yield_now() {
None
struct yieldnow {
None
yielded: bool,
None
}
None
impl std::future::future for yieldnow {
None
type output = ();
None
fn poll(mut self: std::pin::pin<&mut self>, cx: &mut std::task::context<'_>) -> std::task::poll<self::output> {
None
if self.yielded {
None
std::task::poll::ready(())
None
} else {
None
cx.waker().wake_by_ref();
None
self.yielded = true;
None
std::task::poll::pending
None
}
None
}
None
}
None
yieldnow { yielded: false }.await;
None
}


inputs.into_iter().map(move |input| {
(inputs_copy.clone(), input.to_string())
})
}
}

batched(async {
let mut one = loader(1);
let mut two = loader(2);
let mut three = loader(3).

one.schedule().

yielding without delay_loading_batches will cause the batch to load
yield_now().await.



delay_loading_batches enables accumulating batches across yields
let guard = delay_loading_batches();
two.schedule();
yield_now().await;
drop(guard).

let three = three.await.


inputs . into_iter () . map ( move |input| { ( inputs_copy . clone () input . to_string () ) } ) } } batched ( async { let mut one = loader ( 1 ) ; let mut two = loader ( 2 ) ; let mut three = loader ( 3 ) . one . schedule () . yielding without delay_loading_batches will cause the batch to load yield_now () . await . delay_loading_batches enables accumulating batches across yields let guard = delay_loading_batches () ; two . schedule () ; yield_now () . await ; drop ( guard ) . let three = three . await .
});
None
panics
Must be called from within a batched() context.
Must be called from within a batched () context .