diff --git a/timely/src/logging.rs b/timely/src/logging.rs index 3e1aa7125..f52f5a161 100644 --- a/timely/src/logging.rs +++ b/timely/src/logging.rs @@ -14,18 +14,19 @@ pub type TimelyProgressLogger = crate::logging_core::Logger where P: EventPusher> { - // None when the logging stream is closed +pub struct BatchLogger where P: EventPusher { time: Duration, event_pusher: P, - _phantom: ::std::marker::PhantomData, + _phantom: ::std::marker::PhantomData, } -impl BatchLogger where P: EventPusher> { +impl BatchLogger where P: EventPusher, C: Container { /// Creates a new batch logger. pub fn new(event_pusher: P) -> Self { BatchLogger { @@ -35,8 +36,8 @@ impl BatchLogger where P: EventPusher> } } /// Publishes a batch of logged events and advances the capability. - pub fn publish_batch(&mut self, &time: &Duration, data: &mut Vec<(Duration, T)>) { - if !data.is_empty() { + pub fn publish_batch(&mut self, &time: &Duration, data: &mut Option) { + if let Some(data) = data { self.event_pusher.push(Event::Messages(self.time, std::mem::take(data))); } if self.time < time { @@ -47,7 +48,7 @@ impl BatchLogger where P: EventPusher> self.time = time; } } -impl Drop for BatchLogger where P: EventPusher> { +impl Drop for BatchLogger where P: EventPusher { fn drop(&mut self) { self.event_pusher.push(Event::Progress(vec![(self.time, -1)])); }