1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! A runtime agnostic crete for scheduling async task.
//!
//! # Example
//!
//! Oneshot schedule
//!
//! ```rust,no_run
//! use see_you_later::once;
//! use std::sync::{
//!     atomic::{AtomicBool, Ordering},
//!     Arc,
//! };
//! use std::time::Duration;
//!
//! #[smol_potat::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!     let invoked = Arc::new(AtomicBool::new(false));
//!     let invoked1 = invoked.clone();
//!     let (_, task) = once(Duration::from_secs(1), || async {
//!         invoked1.store(true, Ordering::Relaxed);
//!     });
//!
//!     task.await;
//!
//!     assert_eq!(true, invoked.load(Ordering::Relaxed));
//!     Ok(())
//! }
//! ```
//!
//! Every x schedule
//! ```rust,no_run
//! use see_you_later::every;
//! use smol::{self, Task};
//! use std::time::Duration;
//! use wait_for_me::CountDownLatch;
//! #[smol_potat::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!     let latch = CountDownLatch::new(10);
//!     let inner_latch = latch.clone();
//!     let (cancel, task) = every(Duration::from_millis(100), || async {
//!         inner_latch.count_down().await;
//!     });
//!     Task::spawn(async move {
//!         latch.wait().await;
//!         cancel.cancel().await
//!     })
//!     .detach();
//!     task.await;
//!     Ok(())
//! }
//! ```
//!

#![deny(missing_docs)]

mod cancel;
mod every;
mod once;

pub use every::every;
pub use once::{once, DelayedTask};