pub fn tick(duration: Duration) -> Receiver<Sender<()>> {
    let (send, recv) = sync(0);
    if duration.as_secs() == 0 && duration.subsec_nanos() == 0 {
        // Leak the send channel so that it never gets closed and
        // `recv` never synchronizes.
        ::std::mem::forget(send);
    } else {
        thread::spawn(move || {
            loop {
                thread::sleep(duration);
                let (sdone, rdone) = sync(0);
                send.send(sdone);
                // Block until `sdone` gets closed by the caller.
                rdone.recv();
            }
        });
    }
    recv
}
/// Creates a new rendezvous channel that is "ticked" every duration.
///
/// When `duration` is `0`, no ticks are ever sent.
///
/// When `duration` is non-zero, then a new channel is created and sent at
/// every duration. When the sent channel is dropped, the timer is reset
/// and the process repeats after the duration.
///
/// This is especially convenient because it keeps the ticking in sync with
/// the code that uses it. Namely, the ticks won't "build up."
///
/// N.B. There is no way to reclaim the resources used by this function.
/// If you stop receiving on the channel returned, then the thread spawned by
/// `tick_ms` will block indefinitely.
///
/// # Examples
///
/// This is most useful when used in `chan_select!` because the received
/// sentinel channel gets dropped only after the correspond arm has
/// executed. At which point, the ticker is reset and waits to tick until
/// `duration` milliseconds lapses *after* the `chan_select!` arm is executed.
///
/// ```
/// # #[macro_use] extern crate chan; fn main() {
/// use std::thread;
/// use std::time::Duration;
///
/// let tick = chan::tick(Duration::from_millis(100));
/// let boom = chan::after(Duration::from_millis(500));
/// loop {
///     chan_select! {
///         default => {
///             println!("   .");
///             thread::sleep(Duration::from_millis(50));
///         },
///         tick.recv() => println!("tick."),
///         boom.recv() => { println!("BOOM!"); return; },
///     }
/// }
/// # }
/// ```
Creates a new rendezvous channel that is "ticked" every duration.
When `duration` is `0`, no ticks are ever sent.

When `duration` is non-zero, then a new channel is created and sent at
every duration. When the sent channel is dropped, the timer is reset
and the process repeats after the duration.

This is especially convenient because it keeps the ticking in sync with
the code that uses it. Namely, the ticks won't "build up."


Creates a new rendezvous channel that is " ticked " every duration . When ` duration ` is ` 0 ` no ticks are ever sent . When ` duration ` is non - zero then a new channel is created and sent at every duration . When the sent channel is dropped the timer is reset and the process repeats after the duration . This is especially convenient because it keeps the ticking in sync with the code that uses it . Namely the ticks won ' t " build up . "
pub fn tick(duration: Duration) -> Receiver<Sender<()>> {
    let (send, recv) = sync(0);
    if duration.as_secs() == 0 && duration.subsec_nanos() == 0 {
        // Leak the send channel so that it never gets closed and
        // `recv` never synchronizes.
        ::std::mem::forget(send);
    } else {
        thread::spawn(move || {
            loop {
                thread::sleep(duration);
                let (sdone, rdone) = sync(0);
                send.send(sdone);
                // Block until `sdone` gets closed by the caller.
                rdone.recv();
            }
        });
    }
    recv
}
pub fn tick ( duration : Duration ) -> Receiver < Sender < ( ) > > { let ( send , recv ) = sync ( 0 ) ; if duration . as_secs ( ) == 0 && duration . subsec_nanos ( ) == 0 { // Leak the send channel so that it never gets closed and // `recv` never synchronizes. :: std :: mem :: forget ( send ) ; } else { thread :: spawn ( move | | { loop { thread :: sleep ( duration ) ; let ( sdone , rdone ) = sync ( 0 ) ; send . send ( sdone ) ; // Block until `sdone` gets closed by the caller. rdone . recv ( ) ; } } ) ; } recv }
Creates a new rendezvous channel that is "ticked" every duration.
Creates a new rendezvous channel that is " ticked " every duration .
duration
Duration
duration
Duration
examples
This is most useful when used in `chan_select!` because the received
sentinel channel gets dropped only after the correspond arm has
executed. At which point, the ticker is reset and waits to tick until
`duration` milliseconds lapses *after* the `chan_select!` arm is executed.


This is most useful when used in ` chan_select! ` because the received sentinel channel gets dropped only after the correspond arm has executed . At which point the ticker is reset and waits to tick until ` duration ` milliseconds lapses * after * the ` chan_select! ` arm is executed .
#[macro_use] extern crate chan; fn main() {
use std::thread;
use std::time::Duration.

let tick = chan::tick(Duration::from_millis(100));
let boom = chan::after(Duration::from_millis(500));
loop {
chan_select.
use std :: thread ; use std :: time :: Duration . let tick = chan :: tick ( Duration :: from_millis ( 100 )) ; let boom = chan :: after ( Duration :: from_millis ( 500 )) ; loop { chan_select .
}
None