pub fn repeat_into<G, F>(action_gen: G, tq: TaskQueueHandle) -> Result<TimerActionRepeat>
    where
        G: Fn() -> F + 'static,
        F: Future<Output = Option<Duration>> + 'static,
    {
        let reactor = crate::executor().reactor();
        let timer_id = reactor.register_timer();

        let task = crate::spawn_local_into(
            async move {
                while let Some(period) = action_gen().await {
                    Timer::from_id(timer_id, period).await;
                }
            },
            tq,
        )?;

        Ok(TimerActionRepeat {
            handle: task.detach(),
            timer_id,
            reactor: Rc::downgrade(&reactor),
        })
    }
/// Creates a [`TimerActionRepeat`] that will execute the associated future
/// repeatedly in a specific Task Queue until returns None
///
/// # Arguments
///
/// * `action_gen` a Future to be executed repeatedly. The Future's return
///   value must be
/// Option<Duration>. If [`Some`], It will execute again after Duration
/// elapses. If `None`, it stops.
/// * `tq` the [`TaskQueueHandle`] for the TaskQueue we want.
///
/// # Examples
///
/// ```no_run
/// use glommio::{timer::TimerActionRepeat, Latency, LocalExecutorBuilder, Shares};
/// use std::time::Duration;
///
/// let handle = LocalExecutorBuilder::new()
///     .spawn(|| async move {
///         let tq = glommio::executor().create_task_queue(
///             Shares::default(),
///             Latency::NotImportant,
///             "test",
///         );
///         let action = TimerActionRepeat::repeat_into(
///             || async move {
///                 println!("Execute this!");
///                 Some(Duration::from_millis(100))
///             },
///             tq,
///         )
///         .unwrap();
///         action.join().await; // this never returns
///     })
///     .unwrap();
/// handle.join().unwrap();
/// ```
/// [`Duration`]: https://doc.rust-lang.org/std/time/struct.Duration.html
/// [`TimerActionRepeat`]: struct.TimerActionRepeat.html
/// [`TaskQueueHandle`]: ../struct.TaskQueueHandle.html
Creates a [`TimerActionRepeat`] that will execute the associated future
repeatedly in a specific Task Queue until returns None
Creates a [ ` TimerActionRepeat ` ] that will execute the associated future repeatedly in a specific Task Queue until returns None
pub fn repeat_into<G, F>(action_gen: G, tq: TaskQueueHandle) -> Result<TimerActionRepeat>
    where
        G: Fn() -> F + 'static,
        F: Future<Output = Option<Duration>> + 'static,
    {
        let reactor = crate::executor().reactor();
        let timer_id = reactor.register_timer();
        let task = crate::spawn_local_into(
            async move {
                while let Some(period) = action_gen().await {
                    Timer::from_id(timer_id, period).await;
                }
            },
            tq,
        )?;
        Ok(TimerActionRepeat {
            handle: task.detach(),
            timer_id,
            reactor: Rc::downgrade(&reactor),
        })
    }
pub fn repeat_into < G , F > ( action_gen : G , tq : TaskQueueHandle ) -> Result < TimerActionRepeat > where G : Fn ( ) -> F + ' static , F : Future < Output = Option < Duration > > + ' static , { let reactor = crate :: executor ( ) . reactor ( ) ; let timer_id = reactor . register_timer ( ) ; let task = crate :: spawn_local_into ( async move { while let Some ( period ) = action_gen ( ) . await { Timer :: from_id ( timer_id , period ) . await ; } } , tq , ) ? ; Ok ( TimerActionRepeat { handle : task . detach ( ) , timer_id , reactor : Rc :: downgrade ( & reactor ) , } ) }
Creates a [`TimerActionRepeat`] that will execute the associated future
repeatedly in a specific Task Queue until returns None
Creates a [ ` TimerActionRepeat ` ] that will execute the associated future repeatedly in a specific Task Queue until returns None
action_gen
G
tq
TaskQueueHandle
action_gen
G
tq
TaskQueueHandle
examples
```no_run
use glommio::{timer::TimerActionRepeat, Latency, LocalExecutorBuilder, Shares};
use std::time::Duration.


` ` ` no_run use glommio :: { timer :: TimerActionRepeat Latency LocalExecutorBuilder Shares } ; use std :: time :: Duration .