File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,24 @@ This is a library, with an API inspired by [timer.rs](https://github.com/Yoric/t
4
4
[ ![ Documentation] ( https://docs.rs/synchronous-timer/badge.svg )] ( https://docs.rs/synchronous-timer )
5
5
[ ![ crates.io] ( https://img.shields.io/crates/v/synchronous-timer.svg )] ( https://crates.io/crates/synchronous-timer )
6
6
7
+ Example:
8
+
9
+ ``` rust
10
+ use std :: time :: Duration ;
11
+ use synchronous_timer :: Timer ;
12
+
13
+ fn main () {
14
+ let mut timer = Timer :: new ();
15
+ timer
16
+ . schedule_in (Duration :: from_secs (5 ), || {
17
+ println! (" I will run on the background thread in 5 seconds" )
18
+ })
19
+ . detach ();
20
+ timer . schedule_immediately (|| println! (" I will run on the background thread right now" ));
21
+ let handle = timer . schedule_in (Duration :: from_secs (1 ), || println! (" I will never run" ));
22
+ drop (handle );
23
+ std :: thread :: sleep (Duration :: from_secs (6 ));
24
+ }
25
+ ```
26
+
7
27
This work is licensed under the ISC license, a copy of which can be found in [ LICENSE.txt] ( LICENSE.txt ) .
You can’t perform that action at this time.
0 commit comments