You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm storing a struct which is relatively "heavy", but in certain situations I need the capability to swap elements between indexes. Remove current returns &T when I need T, so I need to do a .clone() on the returned value.
Perhaps it's possible to add a swap() method ?
The text was updated successfully, but these errors were encountered:
The reason papaya returns T is because there may be readers that still have access to the value being removed. It may be possible to add a remove_blocking method that waits for all readers to stop accessing a given value, but this may be more expensive than expected as memory reclamation is performed in batches. You could also implement this yourself with a one shot channel and a custom Drop implementation.
There's also no hardware instruction for swapping two atomic pointers, so a swap method would require locks or a complex atomic algorithm that I'm not sure is worth it.
If the clone is very expensive for you your only alternative is unfortunately fine-grained locking on each value.
I'm storing a struct which is relatively "heavy", but in certain situations I need the capability to swap elements between indexes. Remove current returns &T when I need T, so I need to do a
.clone()
on the returned value.Perhaps it's possible to add a
swap()
method ?The text was updated successfully, but these errors were encountered: