Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove uses of time::Instant from core DD #485

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
43 changes: 2 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 @@ -785,6 +744,8 @@ pub mod sink {
// {
// super::source::build(scope, |activator| {
// let source = KafkaSource::new(addr, topic, group, activator);
// // An iterator combinator that yields every "duration" even if more items exist.
// // The implementation of such an iterator exists in the git history, or can be rewritten easily.
// super::YieldingIter::new_from(Iter::<D,T,R>::new_from(source), std::time::Duration::from_millis(10))
// })
// }
Expand Down