diff --git a/kernel/async_channel/src/lib.rs b/kernel/async_channel/src/lib.rs index 59c7feaa87..4bb2ab32dc 100644 --- a/kernel/async_channel/src/lib.rs +++ b/kernel/async_channel/src/lib.rs @@ -325,14 +325,20 @@ impl Sender { pub fn is_disconnected(&self) -> bool { self.channel.is_disconnected() } - + + /// Returns a receiver of the given channel pub fn receiver(&self) -> Receiver { Receiver { channel: self.channel.clone(), } - } } + //if self.channel.sender_count.fetch_add(1, Ordering::SeqCst) == 0 { + // self.channel.channel_status.store(ChannelStatus::Connected); + //} + //Sender { channel: self.channel.clone() } + + /// The receiver side of a channel. pub struct Receiver { channel: Arc>, @@ -485,7 +491,8 @@ impl Receiver { pub fn is_disconnected(&self) -> bool { self.channel.is_disconnected() } - + + /// Returns a sender of the given channel pub fn sender(&self) -> Sender { Sender { channel: self.channel.clone(), @@ -493,9 +500,7 @@ impl Receiver { } } - -/// When the only remaining `Receiver` is dropped, we mark the channel as disconnected -/// and notify all of the `Senders` +/// Drop implementation marks the channel state and notifies the `Sender` impl Drop for Receiver { fn drop(&mut self) { // trace!("Dropping a receiver"); @@ -506,8 +511,7 @@ impl Drop for Receiver { } } -/// When the only remaining `Sender` is dropped, we mark the channel as disconnected -/// and notify all of the `Receivers` +/// Drop implementation marks the channel state and notifies the `Receiver` impl Drop for Sender { fn drop(&mut self) { // trace!("Dropping a sender");