ChannelReceiver

Struct ChannelReceiver 

Source
pub(crate) struct ChannelReceiver(pub(in core) GcHeap<ChannelReceiverInner>);
Expand description

The receiving half of a channel.

Tuple Fields§

§0: GcHeap<ChannelReceiverInner>

Implementations§

Source§

impl ChannelReceiver

Source

pub(in core) fn new( channel_id: u64, manager: Arc<ChannelManager>, constant: bool, ) -> Self

Source

pub(crate) fn recv<'ob>( &self, cx: &'ob Context<'_>, ) -> Result<Gc<ObjectType<'ob>>, RecvError>

Receive an object from the channel, blocking if empty. Returns Err(RecvError::Closed) if all senders have been dropped.

Source

pub(crate) fn try_recv<'ob>( &self, cx: &'ob Context<'_>, ) -> Result<Gc<ObjectType<'ob>>, RecvError>

Try to receive without blocking. Returns Err(RecvError::Empty) if the channel is empty. Returns Err(RecvError::Closed) if all senders have been dropped.

Source

pub(crate) fn recv_timeout<'ob>( &self, cx: &'ob Context<'_>, timeout: Duration, ) -> Result<Gc<ObjectType<'ob>>, RecvError>

Receive with a timeout. Returns Err(RecvError::Timeout) if the timeout expires. Returns Err(RecvError::Closed) if all senders have been dropped.

Source

pub(crate) fn close(&self)

Explicitly close the receiver side of the channel. This wakes up any senders waiting on send() and causes them to return Err(SendError::Closed). This is idempotent - calling close() multiple times has no additional effect.

Useful for “moving” a receiver to another thread: the original receiver can be closed after being cloned into a new context.

Trait Implementations§

Source§

impl<'new> CloneIn<'new, &'new ChannelReceiver> for ChannelReceiver

Source§

fn clone_in<const C: bool>(&self, _bk: &'new Block<C>) -> Gc<&'new Self>

Source§

impl Debug for ChannelReceiver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ChannelReceiver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'ob> From<&'ob ChannelReceiver> for Gc<ObjectType<'ob>>

Source§

fn from(x: &'ob ChannelReceiver) -> Self

Converts to this type from the input type.
Source§

impl GcMoveable for ChannelReceiver

Source§

type Value = NonNull<ChannelReceiver>

Source§

fn move_value(&self, to_space: &Bump) -> Option<(Self::Value, bool)>

Source§

impl IntoObject for ChannelReceiver

Source§

type Out<'ob> = &'ob ChannelReceiver

Source§

fn into_obj<const C: bool>(self, block: &Block<C>) -> Gc<Self::Out<'_>>

Source§

impl PartialEq for ChannelReceiver

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TaggedPtr for &ChannelReceiver

Source§

const TAG: Tag = Tag::ChannelReceiver

Tag value. This is only applicable to base values. Use Int for sum types.
Source§

type Ptr = ChannelReceiver

The type of object being pointed to. This will be different for all implementors.
Source§

unsafe fn from_obj_ptr(ptr: *const u8) -> Self

Given an untyped pointer, reinterpret to self. Read more
Source§

fn get_ptr(self) -> *const Self::Ptr

Get the underlying pointer. Read more
Source§

unsafe fn tag_ptr(ptr: *const Self::Ptr) -> Gc<Self>

Given a pointer to Ptr return a Tagged pointer. Read more
Source§

fn untag(val: Gc<Self>) -> Self

Remove the tag from the Gc<T> and return the inner type. If it is base type then it will only have a single possible value and can be untagged without checks, but sum types need to create all values they can hold. We use tagged base types to let us reinterpret bits without actually modify them. Read more
Source§

fn tag(self) -> Gc<Self>

Given the type, return a tagged version of it. When using a sum type or an immediate value like i64, we override this method to set the proper tag. Read more
Source§

impl<'old, 'new> WithLifetime<'new> for &'old ChannelReceiver

Source§

type Out = &'new ChannelReceiver

Source§

unsafe fn with_lifetime(self) -> Self::Out

Source§

impl Eq for ChannelReceiver

Source§

impl GcPtr for &ChannelReceiver

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V