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

#337 in Concurrency

Download history 96/week @ 2024-08-03 89/week @ 2024-08-10 84/week @ 2024-08-17 79/week @ 2024-08-24 62/week @ 2024-08-31 47/week @ 2024-09-07 82/week @ 2024-09-14 127/week @ 2024-09-21 69/week @ 2024-09-28 26/week @ 2024-10-05 54/week @ 2024-10-12 52/week @ 2024-10-19 61/week @ 2024-10-26 60/week @ 2024-11-02 20/week @ 2024-11-09 21/week @ 2024-11-16

162 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