21 releases
0.4.15 | Feb 21, 2024 |
---|---|
0.4.10 | Dec 8, 2023 |
0.4.9 | Nov 22, 2023 |
0.4.5 | Jun 30, 2023 |
0.1.3 | Mar 8, 2022 |
#311 in Concurrency
227 downloads per month
Used in 42 crates
(16 directly)
170KB
2.5K
SLoC
封装了与共享相关的数据结构,可通过编译条件指定是单线程共享还是多线程共享。
例如,Share类型,通过控制编译条件,可转换为Arc或Xrc
lib.rs
:
默认 不带 任何 feature
1. 几个类型封装
Share
=Xrc
|Arc
ShareWeak
=xrc::Weak
|sync::Weak
ShareMutex
=LockCell(RefCell<T>)
| MutexShareRwLock
=LockCell(RefCell<T>)
|RwLock
ShareCell
=cell::TrustCell
SharePtr
=SyncUnsafeCell<T>
|AtomicPtr<T>
ShareRefCell
=XrcCell<T>
|ArcCell<T>
ShareBool
=SyncUnsafeCell<bool>
|AtomicBool
ShareU8
=SyncUnsafeCell<u8>
|AtomicU8
ShareU32
=SyncUnsafeCell<u32>
|AtomicU32
ShareUsize
=SyncUnsafeCell<usize>
|AtomicUsize
2. 提供 Send, Sync 的 封装
目的:wasm 不支持 Send + Sync
- ThreadSend = Send
- ThreadSync = Sync + Send