pub struct SwmrCell<T: 'static> { /* private fields */ }Expand description
A single-writer, multi-reader cell with version-based garbage collection.
SwmrCell provides safe concurrent access where one writer can update the value
and multiple readers can read it concurrently. Readers access the value by
creating a LocalReader and pinning it.
单写多读单元,带有基于版本的垃圾回收。
SwmrCell 提供安全的并发访问,其中一个写入者可以更新值,
多个读者可以并发读取它。读者通过创建 LocalReader 并 pin 来访问值。
Implementations§
Source§impl<T: 'static> SwmrCell<T>
impl<T: 'static> SwmrCell<T>
Sourcepub fn new(data: T) -> Self
pub fn new(data: T) -> Self
Create a new SWMR cell with default settings and the given initial value.
使用默认设置和给定的初始值创建一个新的 SWMR 单元。
Sourcepub fn builder() -> SwmrCellBuilder<T>
pub fn builder() -> SwmrCellBuilder<T>
Returns a builder for configuring the SWMR cell.
返回用于配置 SWMR 单元的构建器。
Sourcepub fn local(&self) -> LocalReader<T>
pub fn local(&self) -> LocalReader<T>
Create a new LocalReader for reading.
Each thread should create its own LocalReader and reuse it.
LocalReader is !Sync and should not be shared between threads.
创建一个新的 LocalReader 用于读取。
每个线程应该创建自己的 LocalReader 并重复使用。
LocalReader 是 !Sync 的,不应在线程之间共享。