Closed beckend closed 2 months ago
Unfortunately, Ptr
can never be Send
since it relies on its thread-local storage to pin the referenced instance in memory; that's what epoch-based reclamation is for: same applies to Guard
.
In order to send a reference to the data, you'll have to make Shared
out of AtomicShared
through AtomicShared::get_shared
. Shared
holds a strong reference to the instance, so it can be sent across threads and awaits.
Hope this explanation helps you!
In short, Ptr
and Guard
cannot be sent across await
and spawn
.
Please add more examples in the examples folder.
I'll enhance the examples, but you'll be able to find a lot of resources on the internet for crossbeam_epoch
. scc::ebr
is a subset of crossbeam_epoch
(though the implementation is substantially different) + reference counting for easier use.
Updated examples in https://github.com/wvwwvwwv/scalable-delayed-dealloc/
I am trying to integrate AtomicShared in my codebase, however creating an async function and spawning it in a thread is impossible when Ptr is !Send.