Function tick
fn tick(duration: Duration) -> Receiver<Instant>
Creates a receiver that delivers messages periodically.
The channel is bounded with capacity of 1 and never gets disconnected. Messages will be
sent into the channel in intervals of duration. Each message is the instant at which it is
sent.
Examples
Using a tick channel to periodically print elapsed time:
use ;
use tick;
let start = now;
let ticker = tick;
for _ in 0..5
When messages get sent:
use thread;
use ;
use tick;
// Converts a number of milliseconds into a `Duration`.
let ms = ;
// Returns `true` if `a` and `b` are very close `Instant`s.
let eq = ;
let start = now;
let r = tick;
// This message was sent 100 ms from the start and received 100 ms from the start.
assert!;
assert!;
sleep;
// This message was sent 200 ms from the start and received 600 ms from the start.
assert!;
assert!;
// This message was sent 700 ms from the start and received 700 ms from the start.
assert!;
assert!;