diff --git a/src/cell/datacell.rs b/src/cell/datacell.rs index ce815b1..e733beb 100644 --- a/src/cell/datacell.rs +++ b/src/cell/datacell.rs @@ -94,10 +94,10 @@ where /// Retrieves the data from the cell pub fn get(&self) -> Result
{ let mut value = self.inner.value.lock(); - if value.closed { - return Err(Error::ChannelClosed); - } loop { + if value.closed { + return Err(Error::ChannelClosed); + } if let Some(current) = value.current.take() { return Ok(current); } @@ -109,10 +109,10 @@ where /// Retrieves the data from the cell with the given timeout pub fn get_timeout(&self, timeout: Duration) -> Result
{
let mut value = self.inner.value.lock();
- if value.closed {
- return Err(Error::ChannelClosed);
- }
loop {
+ if value.closed {
+ return Err(Error::ChannelClosed);
+ }
if let Some(current) = value.current.take() {
return Ok(current);
}
@@ -180,6 +180,19 @@ mod test {
handle.join().unwrap();
}
+ #[test]
+ fn test_datacell_close_empty() {
+ let cell: DataCell