Skip to content

Preventing False Sharing and Contention #3605

Answered by Darksonn
computerquip asked this question in Q&A
Discussion options

You must be logged in to vote

One option you may go for is the arc-swap crate. This lets you clone the state only on each change, and any requests using it while you update it will continue to use the old value, but new requests would use the new one. The old value would be destroyed when the last requests using the old one finishes.

Another option is to go for the watch channel. This channel only retains the last value and lets you access the current value without cloning. However it doesn't have the property that requests can keep using the old one as the current value is stored in a read-write lock.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@computerquip-work
Comment options

Answer selected by Darksonn
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants