1#![feature(sync_unsafe_cell)]
25#![feature(const_trait_impl)]
26#![feature(allocator_api)]
27#![feature(arbitrary_self_types)]
29#![feature(strict_provenance)]
30#![feature(error_in_core)]
31#![feature(error_generic_member_access)]
32#![feature(layout_for_ptr)]
33#![feature(trusted_len)]
34#![feature(slice_ptr_get)]
35#![feature(set_ptr_value)]
36#![feature(alloc_layout_extra)]
37
38pub mod arc_cell;
39pub mod atomic;
40pub mod cell;
41pub mod lock;
42pub mod xrc;
43pub mod xrc_cell;
44
45pub type ShareCell<T> = cell::TrustCell<T>;
46pub type Cell<T> = cell::TrustCell<T>;
47
48#[cfg(feature = "serial")]
49pub trait ThreadSend {}
50#[cfg(feature = "serial")]
51impl<T> ThreadSend for T {}
52#[cfg(feature = "serial")]
53pub trait ThreadSync {}
54#[cfg(feature = "serial")]
55impl<T> ThreadSync for T {}
56
57#[cfg(not(feature = "serial"))]
58pub trait ThreadSend: Send {}
59#[cfg(not(feature = "serial"))]
60impl<T: Send> ThreadSend for T {}
61#[cfg(not(feature = "serial"))]
62pub trait ThreadSync: Sync + Send {}
63#[cfg(not(feature = "serial"))]
64impl<T: Sync + Send> ThreadSync for T {}
65
66#[cfg(feature = "rc")]
67pub type Share<T> = Xrc<T>;
68#[cfg(feature = "rc")]
69pub type ShareWeak<T> = xrc::Weak<T>;
70#[cfg(feature = "rc")]
71pub type ShareMutex<T> = crate::lock::LockCell<T>;
72#[cfg(feature = "rc")]
73pub type ShareRwLock<T> = crate::lock::LockCell<T>;
74#[cfg(feature = "rc")]
75pub type SharePtr<T> = crate::atomic::AtomicCell<T>;
76#[cfg(feature = "rc")]
77pub type ShareBool = crate::atomic::AtomicCell<bool>;
78#[cfg(feature = "rc")]
79pub type ShareU8 = crate::atomic::AtomicCell<u8>;
80#[cfg(feature = "rc")]
81pub type ShareUsize = crate::atomic::AtomicCell<usize>;
82#[cfg(feature = "rc")]
83pub type ShareU32 = crate::atomic::AtomicCell<u32>;
84#[cfg(feature = "rc")]
85pub type ShareU64 = crate::atomic::AtomicCell<u64>;
86#[cfg(feature = "rc")]
87pub use xrc_cell::XrcCell as ShareRefCell;
88#[cfg(feature = "rc")]
89#[inline(always)]
90pub fn fence(or: std::sync::atomic::Ordering) {}
91
92#[cfg(not(feature = "rc"))]
93use std::sync::{
94 atomic::{AtomicBool, AtomicPtr, AtomicU32, AtomicU64, AtomicU8, AtomicUsize},
95 Arc, Mutex, RwLock, Weak,
96};
97
98#[cfg(not(feature = "rc"))]
99pub type Share<T> = Arc<T>;
100#[cfg(not(feature = "rc"))]
101pub type ShareWeak<T> = Weak<T>;
102#[cfg(not(feature = "rc"))]
103pub type ShareMutex<T> = Mutex<T>;
104#[cfg(not(feature = "rc"))]
105pub type ShareRwLock<T> = RwLock<T>;
106#[cfg(not(feature = "rc"))]
107pub type SharePtr<T> = AtomicPtr<T>;
108#[cfg(not(feature = "rc"))]
109pub type ShareBool = AtomicBool;
110#[cfg(not(feature = "rc"))]
111pub type ShareU8 = AtomicU8;
112#[cfg(not(feature = "rc"))]
113pub type ShareUsize = AtomicUsize;
114#[cfg(not(feature = "rc"))]
115pub type ShareU32 = AtomicU32;
116#[cfg(not(feature = "rc"))]
117pub type ShareU64 = AtomicU64;
118#[cfg(not(feature = "rc"))]
119pub use arc_cell::ArcCell as ShareRefCell;
120#[cfg(not(feature = "rc"))]
121#[inline(always)]
122pub fn fence(or: std::sync::atomic::Ordering) {
123 std::sync::atomic::fence(or)
124}