I tried AtomicPtr<T>
and Arc<AtomicPtr<T>>
, but all failed.
error: the trait core::marker::Send is not implemented for the type *mut usize [E0277]
.
How can i share it between threads?
I tried AtomicPtr<T>
and Arc<AtomicPtr<T>>
, but all failed.
error: the trait core::marker::Send is not implemented for the type *mut usize [E0277]
.
How can i share it between threads?
There really is no good way for the compiler to know that its okay to Send a *mut ptr. I'll assume that you are taking the appropriate steps to ensure that access to the ptr and what it points to is properly checked. In that case, I might recommend doing an
unsafe impl Send for Foo {} // where Foo is your struct which contains the AtomicPtr.
This seems like a bug to me since obviously if you put a pointer into AtomicPtr its to share it.
Looking at the source, it seems quite intentional. Maybe it is a remnant from when only 'static was Send-able?