1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//! Platform-specific synchronization primitives
//!
//! This module provides cross-platform abstractions for synchronization primitives
//! that work on both native (tokio) and WASM targets.
//!
//! On native targets, we use tokio's async synchronization primitives.
//! On WASM, we use std::sync primitives (which work because WASM is single-threaded)
//! and futures::channel for message passing.
// Re-export platform-specific RwLock
pub use RwLock;
pub use RwLock;
// Re-export platform-specific Mutex
pub use Mutex;
pub use Mutex;
// Re-export platform-specific mpsc channels
pub use mpsc;
pub use mpsc;
/// Helper macro for acquiring a read lock.
///
/// On native targets, this awaits the async lock.
/// On WASM, this uses the blocking (but single-threaded safe) lock.
///
/// # Lock Poisoning (WASM only)
///
/// On WASM targets, lock poisoning is recovered by taking the inner guard.
/// This avoids panic-only behavior in adapter/runtime helpers.
///
/// # Example
///
/// ```ignore
/// let guard = read_lock!(self.data);
/// println!("{:?}", *guard);
/// ```
/// Helper macro for acquiring a write lock.
///
/// On native targets, this awaits the async lock.
/// On WASM, this uses the blocking (but single-threaded safe) lock.
///
/// # Lock Poisoning (WASM only)
///
/// On WASM targets, lock poisoning is recovered by taking the inner guard.
/// This avoids panic-only behavior in adapter/runtime helpers.
///
/// # Example
///
/// ```ignore
/// let mut guard = write_lock!(self.data);
/// *guard = new_value;
/// ```
/// Helper macro for acquiring a mutex lock.
///
/// On native targets, this awaits the async lock.
/// On WASM, this uses the blocking (but single-threaded safe) lock.
///
/// # Lock Poisoning (WASM only)
///
/// On WASM targets, lock poisoning is recovered by taking the inner guard.
/// This avoids panic-only behavior in adapter/runtime helpers.
///
/// # Example
///
/// ```ignore
/// let guard = mutex_lock!(self.state);
/// process(&*guard);
/// ```
// Re-export macros for use within the crate
pub use cratemutex_lock;
pub use crateread_lock;
pub use cratewrite_lock;