pub fn run_pending(&mut self) -> AsyncSchedulerFuture {
        let now = Tp::now(&self.tz);
        let mut futures = vec![];
        for job in &mut self.jobs {
            if job.is_pending(&now) {
                if let Some(future) = job.execute(&now) {
                    futures.push(Some(future.into()));
                }
            }
        }
        AsyncSchedulerFuture { futures }
    }
/// Run all jobs that should run at this time.
///
/// This method returns a future that will poll each of the tasks until they are completed.
/// ```no_run
/// # use clokwerk::*;
/// # use clokwerk::Interval::*;
/// use std::time::Duration;
/// # let mut scheduler = AsyncScheduler::new();
/// # async {
/// loop {
///     scheduler.run_pending().await;
///     tokio::time::sleep(Duration::from_millis(100)).await;
///     # break
/// }
/// # };
/// ```
/// Note that while all pending jobs will run asynchronously, a long-running task can still
/// block future executions if you `await` the future returned by this method.
/// If you are concerned that a task might run for a long time, there are several possible approaches:
///
/// 1. Pass the result of `scheduler.run_pending()` to your runtime's `spawn` function. This might
///    result in multiple invocations of the same task running concurrently.
/// 2. Use `spawn` or `spawn_blocking` in your task itself. This has the same concurrent execution risk
///    as approach 1, but limited to that specific task.
/// 3. Use `tokio::time::timeout` or equivalent to prevent `scheduler.run_pending()` or the task itself
///    from running more than an expected amount of time. E.g.
/// ```no_run
/// # use clokwerk::*;
/// # use clokwerk::Interval::*;
/// # async fn scrape_pages() {}
/// use std::time::Duration;
/// let mut scheduler = AsyncScheduler::new();
/// scheduler.every(10.minutes()).run(|| async {
///   if let Err(_) = tokio::time::timeout(Duration::from_secs(10 * 60), scrape_pages()).await {
///     eprintln!("Timed out scraping pages")
///   }
/// });
/// ```
Run all jobs that should run at this time.
This method returns a future that will poll each of the tasks until they are completed.
Run all jobs that should run at this time . This method returns a future that will poll each of the tasks until they are completed .
pub fn run_pending(&mut self) -> AsyncSchedulerFuture {
        let now = Tp::now(&self.tz);
        let mut futures = vec![];
        for job in &mut self.jobs {
            if job.is_pending(&now) {
                if let Some(future) = job.execute(&now) {
                    futures.push(Some(future.into()));
                }
            }
        }
        AsyncSchedulerFuture { futures }
    }
pub fn run_pending ( & mut self ) -> AsyncSchedulerFuture { let now = Tp :: now ( & self . tz ) ; let mut futures = vec ! [ ] ; for job in & mut self . jobs { if job . is_pending ( & now ) { if let Some ( future ) = job . execute ( & now ) { futures . push ( Some ( future . into ( ) ) ) ; } } } AsyncSchedulerFuture { futures } }
Run all jobs that should run at this time.
Run all jobs that should run at this time .
&mut self
use clokwerk::*;
None
use clokwerk::interval::*;
None
let mut scheduler = asyncscheduler::new();
None
async {
loop {
scheduler.run_pending().await;
tokio::time::sleep(Duration::from_millis(100)).await;
break
}
loop { scheduler . run_pending () . await ; tokio :: time :: sleep ( Duration :: from_millis ( 100 )) . await ; break }
};
```
Note that while all pending jobs will run asynchronously, a long-running task can still
block future executions if you `await` the future returned by this method.
If you are concerned that a task might run for a long time, there are several possible approaches.

1. Pass the result of `scheduler.run_pending()` to your runtime's `spawn` function. This might
result in multiple invocations of the same task running concurrently.
2. Use `spawn` or `spawn_blocking` in your task itself. This has the same concurrent execution risk
as approach 1, but limited to that specific task.
3. Use `tokio::time::timeout` or equivalent to prevent `scheduler.run_pending()` or the task itself
from running more than an expected amount of time. E.g.
` ` ` Note that while all pending jobs will run asynchronously a long - running task can still block future executions if you ` await ` the future returned by this method . If you are concerned that a task might run for a long time there are several possible approaches . 1 . Pass the result of ` scheduler . run_pending () ` to your runtime ' s ` spawn ` function . This might result in multiple invocations of the same task running concurrently . 2 . Use ` spawn ` or ` spawn_blocking ` in your task itself . This has the same concurrent execution risk as approach 1 but limited to that specific task . 3 . Use ` tokio :: time :: timeout ` or equivalent to prevent ` scheduler . run_pending () ` or the task itself from running more than an expected amount of time . E . g .
use clokwerk::*;
None
use clokwerk::interval::*;
None
async fn scrape_pages() {}
use std::time::Duration;
let mut scheduler = AsyncScheduler::new();
scheduler.every(10.minutes()).run(|| async {
if let Err(_) = tokio::time::timeout(Duration::from_secs(10 * 60), scrape_pages()).await {
eprintln!("Timed out scraping pages")
}
});
```
use std :: time :: Duration ; let mut scheduler = AsyncScheduler :: new () ; scheduler . every ( 10 . minutes () ) . run ( || async { if let Err ( _ ) = tokio :: time :: timeout ( Duration :: from_secs ( 10 * 60 ) scrape_pages () ) . await { eprintln! ( " Timed out scraping pages " ) } } ) ; ` ` `