@@ -61,17 +61,20 @@ pub trait TimerBase: Send + Sync {
6161
6262/// A struct for triggering a callback at regular intervals.
6363///
64- /// Calling [`spin_once `][1] or [`spin `][2] on the timer's node will wait until the configured
65- /// period of time has passed since the timer was last called (or since it was created) before
66- /// triggering the timer's callback.
64+ /// If created via [`Node::create_timer() `][1], calling [`spin_once `][2] or [`spin`][3]
65+ /// on the timer's node will wait until the configured period of time has passed since
66+ /// the timer was last called (or since it was created) before triggering the timer's callback.
6767///
68- /// The only available way to instantiate timers is via [`Node::create_timer()`][3], this
69- /// is to ensure that [`Node`][4]s can track all the timers that have been created.
68+ /// If created via [`Timer::new`], [`is_ready`][4] must be polled until the timer has
69+ /// expired, after which [`execute`][5] must be called to trigger the timer's callback.
70+ /// The timer can also be added to a [`WaitSet`][6] to block until it is ready.
7071///
71- /// [1]: crate::spin_once
72- /// [2]: crate::spin
73- /// [3]: crate::Node::create_timer
74- /// [4]: crate::Node
72+ /// [1]: crate::Node::create_timer
73+ /// [2]: crate::spin_once
74+ /// [3]: crate::spin
75+ /// [4]: crate::Timer::is_ready
76+ /// [5]: crate::Timer::execute
77+ /// [6]: crate::WaitSet
7578pub struct Timer {
7679 callback : Arc < Mutex < dyn FnMut ( & mut Timer ) + Send + Sync > > ,
7780 handle : TimerHandle ,
@@ -80,6 +83,12 @@ pub struct Timer {
8083impl Timer {
8184 /// Creates a new `Timer` with the given period and callback.
8285 /// Periods greater than i64::MAX nanoseconds will saturate to i64::MAX.
86+ ///
87+ /// Note that most of the time [`Node::create_timer`][1] is the better way to make
88+ /// a new timer, as that will allow the timer to be triggered by spinning the node.
89+ /// Timers created with [`Timer::new`] must be checked and executed by the user.
90+ ///
91+ /// [1]: crate::Node::create_timer
8392 pub fn new < F > (
8493 context : & Context ,
8594 clock : Clock ,
0 commit comments