Struct fastsend::BlockFrame[][src]

pub struct BlockFrame<T> { /* fields omitted */ }
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

Trait Implementations

Formats the value using the given formatter. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.