Closed Ten0 closed 3 years ago
Yes, this is not intentional. I'll have a look, hopefully soon.
(As a side note, if this code isn't just a minimized example for demonstration, it seems very similar to what once_cell
does)
Quick discovery: It's not implemented for Option<Arc<_>>
, but it is for &Option<Arc<_>>
, so &None::<Arc<_>>
or std::ptr::null()
will work.
I'll have to check first if there's a good reason why it isn't implemented for Option
directly before adding the implementation.
(As a side note, if this code isn't just a minimized example for demonstration, it seems very similar to what
once_cell
does)
Hmm it is but looks like for my use-case I can indeed use a combination of OnceCell
and ArcSwap
instead of ArcSwap
and Arc
. Thanks! :)
So, the reason why it's not for owned is that I get conflicting implementations :-(. I've at least tried to improve the documentation.
It seems we can't use
compare_and_swap(None)
forArcSwapOption
:It seems this is not an technical limitation but rather an interface limitation, as
AtomicPtr
hascompare_and_swap
forNULL
. Is there any way we could achieve this?