Skip to content
Snippets Groups Projects
Commit b039b6ef authored by Dorian Weber's avatar Dorian Weber
Browse files

Fixed a bug with the channels.

parent 8d922d13
No related merge requests found
......@@ -671,6 +671,22 @@ impl<T: Unpin> Sender<T> {
}
}
impl<T> Drop for Sender<T> {
#[inline]
fn drop(&mut self) {
// check if there are still receivers
if let Some(chan) = self.0.upgrade() {
// check if we're the last sender to drop
if Rc::weak_count(&chan) == 1 {
// awake all of the waiting receivers so that they get to return
for process in chan.borrow_mut().waiting.drain(..) {
process.wake();
}
}
}
}
}
impl<T: Unpin> Receiver<T> {
/// Returns a future that can be awaited to receive a message.
pub fn recv(&self) -> ReceiveFuture<T> {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment