kovan_map/maybe_send.rs
1//! What the maps ask of a key or value so that freeing it on another thread is sound.
2
3/// `Send` on every target where threads can share memory, which is every target but wasm32
4/// without the `atomics` feature. A replaced or removed entry is freed on whichever thread frees
5/// its batch, so there its key and value must be `Send`.
6#[cfg(not(all(target_arch = "wasm32", not(target_feature = "atomics"))))]
7pub trait MaybeSend: Send {}
8
9#[cfg(not(all(target_arch = "wasm32", not(target_feature = "atomics"))))]
10impl<T: Send + ?Sized> MaybeSend for T {}
11
12/// Nothing on wasm32 without the `atomics` feature: the program has one thread, every entry is
13/// freed on it, so a map may hold keys and values that are not `Send` (an `Rc`).
14#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))]
15pub trait MaybeSend {}
16
17#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))]
18impl<T: ?Sized> MaybeSend for T {}