BlockFrame

Struct BlockFrame 

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

§BlockFrame 的设计理念

对于特定场景,在事先知道需要构造大量元素 T 的场合,为了避免每次单次生成所花费的边际成本过高,因此使用一定的算法 事先生成特定数量的元素 T,并划分成不同的 Block 使用,每个 Block 被设计成被 Sent 到不同线程以供使用,这 种设计解决了多线程竞争同一个消费队列产生的锁竞争消耗。

一个 Block 在目前的设计中被定义为包含 Block::SIZE=8 个元素的集合,并且实现了 Iterator trait,预示 着其是一个可以生成总计 Block::SIZE 个数元素 T 的生成器。Block 通常会被放置在 thread_local 中使用, 以避免线程间的互相竞争。Block 将会以 &mut Block 的形态出现,因此其在理论上应该是只 SendSync 的。

Implementations§

Source§

impl<T> BlockFrame<T>

Source

pub fn new() -> Self

Source§

impl<T: ConstructBlock> BlockFrame<T>

Source

pub fn next_block( &self, ) -> Pin<Box<dyn Future<Output = Block<T>> + Send + 'static>>
where T: Send + 'static,

Trait Implementations§

Source§

impl<T: Debug> Debug for BlockFrame<T>

Source§

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

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

impl<T> Default for BlockFrame<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for BlockFrame<T>

§

impl<T> RefUnwindSafe for BlockFrame<T>

§

impl<T> Send for BlockFrame<T>
where T: Send,

§

impl<T> Sync for BlockFrame<T>
where T: Send,

§

impl<T> Unpin for BlockFrame<T>

§

impl<T> UnwindSafe for BlockFrame<T>

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> 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

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

Source§

fn vzip(self) -> V