Skip to content

Commit 3521627

Browse files
committed
clean up ring buffer
1 parent 9b66dd0 commit 3521627

File tree

1 file changed

+1
-30
lines changed

1 file changed

+1
-30
lines changed

ring-buffer/src/lib.rs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ impl fmt::Debug for BufferError {
2727
}
2828
}
2929

30-
// Implement the Error trait
3130
impl Error for BufferError {
3231
fn source(&self) -> Option<&(dyn Error + 'static)> {
3332
match self {
@@ -68,26 +67,7 @@ impl RingBuffer {
6867
},
6968
}
7069
}
71-
/*
72-
pub enum TryRecvError {
73-
/// A message could not be received because the channel is empty.
74-
///
75-
/// If this is a zero-capacity channel, then the error indicates that there was no sender
76-
/// available to send a message at the time.
77-
Empty,
7870

79-
/// The message could not be received because the channel is empty and disconnected.
80-
Disconnected,
81-
}
82-
*/
83-
84-
/*
85-
if let Ok(order) = self.depth_consumer.recv() {
86-
self.buffer.push_back(order)
87-
} else {
88-
warn!("no depth to receive")
89-
}
90-
*/
9171
pub fn pop_depth(&mut self) -> Option<DepthUpdate> {
9272
if let Some(order) = self.buffer.pop_front() {
9373
info!("pop_depth in rb");
@@ -98,24 +78,15 @@ impl RingBuffer {
9878
}
9979
pub fn push_back(&mut self, item: DepthUpdate) {
10080
if self.buffer.len() == self.size {
101-
// get rid of the oldest item in the ring buffer before
102-
// pushing an item in the back
10381
self.buffer.pop_front();
10482
}
10583
self.buffer.push_back(item);
10684
}
107-
// possibly remove this function
85+
10886
pub fn push_front(&mut self, item: DepthUpdate) {
10987
if self.buffer.len() == self.size {
11088
self.buffer.pop_back();
11189
}
11290
self.buffer.push_front(item);
11391
}
114-
fn pop_front(&mut self) -> Option<DepthUpdate> {
115-
self.buffer.pop_front()
116-
}
117-
// possibly remove this function
118-
pub fn pop_back(&mut self) -> Option<DepthUpdate> {
119-
self.buffer.pop_back()
120-
}
12192
}

0 commit comments

Comments
 (0)