Skip to content

Commit 09e3de9

Browse files
committed
imp(timer): empty implementation for epoll/kqueue
1 parent f759478 commit 09e3de9

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/timer/epoll.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,23 @@ impl Timer {
2323
self
2424
}
2525

26+
/// Attach an mpsc::Sender to Timer
27+
///
28+
/// Timer will dispatch an event with the timestamp of the current instant,
29+
/// every 10th second to all attached senders
2630
pub fn attach_listener(&mut self, tx: Sender<u64>) -> Result<()> {
31+
// Push Sender to a Vector of Sender(s)
32+
let txs = Arc::clone(&self.txs);
33+
txs.lock()?.push(tx);
34+
2735
Ok(())
2836
}
2937

38+
/// Clear the listeners (txs) from Timer. This will shutdown the Timer thread
3039
pub fn drop_listeners(&mut self) -> Result<()> {
40+
let txs = Arc::clone(&self.txs);
41+
txs.lock()?.clear();
42+
3143
Ok(())
3244
}
3345
}

src/timer/kqueue.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,23 @@ impl Timer {
2323
self
2424
}
2525

26+
/// Attach an mpsc::Sender to Timer
27+
///
28+
/// Timer will dispatch an event with the timestamp of the current instant,
29+
/// every 10th second to all attached senders
2630
pub fn attach_listener(&mut self, tx: Sender<u64>) -> Result<()> {
31+
// Push Sender to a Vector of Sender(s)
32+
let txs = Arc::clone(&self.txs);
33+
txs.lock()?.push(tx);
34+
2735
Ok(())
2836
}
2937

38+
/// Clear the listeners (txs) from Timer. This will shutdown the Timer thread
3039
pub fn drop_listeners(&mut self) -> Result<()> {
40+
let txs = Arc::clone(&self.txs);
41+
txs.lock()?.clear();
42+
3143
Ok(())
3244
}
3345
}

0 commit comments

Comments
 (0)