Hello,
I'm having some issues understanding why this is a problem. When I try to move an Arc<RwLock<T>
to a thread I get a long error message that the Send trait is not implemented for T
and all the members of T
as well.
note: required by a bound in `spawn`
|
625 | F: Send + 'static,
| ^^^^ required by this bound in `spawn`
Here's a snippet of code where this happens:
pub(crate) fn new(swap_chains: Arc<RwLock<SwapChainMap>>) -> Self {
let (thread_sender, thread_receiver) = std::sync::mpsc::channel::<PresentMessage>();
let (response_sender, response_receiver) = std::sync::mpsc::channel::<PresentResultMessage>();
let child = std::thread::spawn(move || loop { // <-- error here
// access swap_chains with write/read
// send/receive messages
});
...
}
SwapChainMap
is typedef for a custom map structure (pub struct HandleMap<H, T>
) and I'm using the 1.57.0 nightly compiler.
Shouldn't this just work? I was under the impression that RwLock
provides Send
and Sync
implementations. Am I missing something?