Skip to content

Commit

Permalink
imp(timer): empty implementation for epoll/kqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
omarabid committed Jan 10, 2022
1 parent f759478 commit 09e3de9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/timer/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,23 @@ impl Timer {
self
}

/// Attach an mpsc::Sender to Timer
///
/// Timer will dispatch an event with the timestamp of the current instant,
/// every 10th second to all attached senders
pub fn attach_listener(&mut self, tx: Sender<u64>) -> Result<()> {
// Push Sender to a Vector of Sender(s)
let txs = Arc::clone(&self.txs);
txs.lock()?.push(tx);

Ok(())
}

/// Clear the listeners (txs) from Timer. This will shutdown the Timer thread
pub fn drop_listeners(&mut self) -> Result<()> {
let txs = Arc::clone(&self.txs);
txs.lock()?.clear();

Ok(())
}
}
12 changes: 12 additions & 0 deletions src/timer/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,23 @@ impl Timer {
self
}

/// Attach an mpsc::Sender to Timer
///
/// Timer will dispatch an event with the timestamp of the current instant,
/// every 10th second to all attached senders
pub fn attach_listener(&mut self, tx: Sender<u64>) -> Result<()> {
// Push Sender to a Vector of Sender(s)
let txs = Arc::clone(&self.txs);
txs.lock()?.push(tx);

Ok(())
}

/// Clear the listeners (txs) from Timer. This will shutdown the Timer thread
pub fn drop_listeners(&mut self) -> Result<()> {
let txs = Arc::clone(&self.txs);
txs.lock()?.clear();

Ok(())
}
}

0 comments on commit 09e3de9

Please sign in to comment.