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

#344 in Concurrency

Download history 85/week @ 2024-08-18 79/week @ 2024-08-25 63/week @ 2024-09-01 72/week @ 2024-09-08 78/week @ 2024-09-15 107/week @ 2024-09-22 67/week @ 2024-09-29 29/week @ 2024-10-06 50/week @ 2024-10-13 52/week @ 2024-10-20 63/week @ 2024-10-27 60/week @ 2024-11-03 18/week @ 2024-11-10 32/week @ 2024-11-17 82/week @ 2024-11-24 78/week @ 2024-12-01

212 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