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

Download history 65/week @ 2024-07-22 120/week @ 2024-07-29 96/week @ 2024-08-05 88/week @ 2024-08-12 89/week @ 2024-08-19 76/week @ 2024-08-26 42/week @ 2024-09-02 72/week @ 2024-09-09 77/week @ 2024-09-16 126/week @ 2024-09-23 47/week @ 2024-09-30 30/week @ 2024-10-07 50/week @ 2024-10-14 72/week @ 2024-10-21 44/week @ 2024-10-28 60/week @ 2024-11-04

227 downloads per month
Used in 42 crates (16 directly)

MIT/Apache

170KB
2.5K SLoC

封装了与共享相关的数据结构,可通过编译条件指定是单线程共享还是多线程共享。

例如,Share类型,通过控制编译条件,可转换为Arc或Xrc


lib.rs:

默认 不带 任何 feature

1. 几个类型封装

  • Share = Xrc | Arc
  • ShareWeak = xrc::Weak | sync::Weak
  • ShareMutex = LockCell(RefCell<T>) | Mutex
  • ShareRwLock = 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

No runtime deps

Features