Skip to main content

AnySender

Struct AnySender 

pub struct AnySender<T> { /* private fields */ }
Expand description

可克隆(Clone)的任一交值句柄(sender handle)。

每份有效句柄可消耗自身交值一次;只有首个获得许可的交值被接受。 无值释放仅结束本份,不会提前结束其它交值方。 T: Send 时可跨线程使用,不额外要求 T: Sync。

Implementations§

Source§

impl<T> AnySender<T>

Source

pub fn send(self, value: T) -> Result<(), SendError<T>>

同步尝试交值并消耗本句柄(handle)。

成功只表示本值胜出并被接受,不承诺等待端已观察到它。 失败通过 SendError 返还同一个原值:已有胜出许可为 SendErrorKind::ValueAlreadyAccepted,否则接收关闭为 SendErrorKind::ReceiverClosed。已有胜出事实不被后续关闭改写。

不分配,不等待接收者或其它交值方;条件原子更新(CAS)可能因真实竞争重试。 通知或清理中的用户恐慌(panic)传播,不回退已确认接受事实; 用户回调耗时不属于非阻塞保证。

Trait Implementations§

Source§

impl<T> Clone for AnySender<T>

Source§

fn clone(&self) -> AnySender<T>

增加一份交值能力;关闭或已有胜出时仅保留固定拒绝原因。

有效克隆(Clone)不分配;本库有效数量越界在发布新份之前恐慌(panic)。 标准共享持有(Arc)自身上限仍沿标准库规则;拒绝份不会增加有效数量。

1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Drop for AnySender<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for AnySender<T>

§

impl<T> !UnwindSafe for AnySender<T>

§

impl<T> Forget for AnySender<T>

§

impl<T> Freeze for AnySender<T>
where AnySenderState<T>: Freeze,

§

impl<T> Move for AnySender<T>

§

impl<T> Send for AnySender<T>
where AnySenderState<T>: Send,

§

impl<T> Sync for AnySender<T>
where AnySenderState<T>: Sync,

§

impl<T> Unpin for AnySender<T>
where AnySenderState<T>: Unpin,

§

impl<T> UnsafeUnpin for AnySender<T>
where AnySenderState<T>: UnsafeUnpin,

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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> OpaqueAttachment for T
where T: Send + Sync + 'static,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.