Skip to content

Commit

Permalink
Remove uses of time::Instant from core DD
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmcsherry committed May 13, 2024
1 parent 869ec47 commit fc5283a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 43 deletions.
2 changes: 0 additions & 2 deletions src/algorithms/graphs/sequential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ where
F: Fn(&N, &[(&V, isize)])->V+'static
{

let _timer = ::std::time::Instant::now();

// start iteration with None messages for all.
state
.map(|(node, _state)| (node, None))
Expand Down
84 changes: 43 additions & 41 deletions src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,47 +42,6 @@ pub struct Progress<T> {
pub counts: Vec<(T, usize)>,
}

/// An iterator that yields with a `None` every so often.
pub struct YieldingIter<I> {
/// When set, a time after which we should return `None`.
start: Option<std::time::Instant>,
after: std::time::Duration,
iter: I,
}

impl<I> YieldingIter<I> {
/// Construct a yielding iterator from an inter-yield duration.
pub fn new_from(iter: I, yield_after: std::time::Duration) -> Self {
Self {
start: None,
after: yield_after,
iter,
}
}
}

impl<I: Iterator> Iterator for YieldingIter<I> {
type Item = I::Item;
fn next(&mut self) -> Option<Self::Item> {
if self.start.is_none() {
self.start = Some(std::time::Instant::now());
}
let start = self.start.as_ref().unwrap();
if start.elapsed() > self.after {
self.start = None;
None
} else {
match self.iter.next() {
Some(x) => Some(x),
None => {
self.start = None;
None
}
}
}
}
}

/// A simple sink for byte slices.
pub trait Writer<T> {
/// Returns an amount of time to wait before retrying, or `None` for success.
Expand Down Expand Up @@ -813,6 +772,49 @@ pub mod sink {

// }

// /// An iterator that yields with a `None` every so often.
// pub struct YieldingIter<I> {
// /// When set, a time after which we should return `None`.
// start: Option<std::time::Instant>,
// after: std::time::Duration,
// iter: I,
// }

// impl<I> YieldingIter<I> {
// /// Construct a yielding iterator from an inter-yield duration.
// pub fn new_from(iter: I, yield_after: std::time::Duration) -> Self {
// Self {
// start: None,
// after: yield_after,
// iter,
// }
// }
// }

// impl<I: Iterator> Iterator for YieldingIter<I> {
// type Item = I::Item;
// fn next(&mut self) -> Option<Self::Item> {
// if self.start.is_none() {
// self.start = Some(std::time::Instant::now());
// }
// let start = self.start.as_ref().unwrap();
// if start.elapsed() > self.after {
// self.start = None;
// None
// } else {
// match self.iter.next() {
// Some(x) => Some(x),
// None => {
// self.start = None;
// None
// }
// }
// }
// }
// }



// pub struct KafkaSource {
// consumer: BaseConsumer<ActivationConsumerContext>,
// }
Expand Down

0 comments on commit fc5283a

Please sign in to comment.