vorner / arc-swap

Support atomic operations on Arc itself
Apache License 2.0
777 stars 31 forks source link

Is it ok to use `ArcSwap` in async environment? #118

Closed byte-sourcerer closed 6 months ago

byte-sourcerer commented 6 months ago

For example, would it causes deadlock in the async environment?

vorner commented 6 months ago

ArcSwap is lock-free. There is no way to cause a deadlock with it.

However, if you hold too many Guards to the same arc-swap, you may get a slight slow-down (we are talking about micro-optimization speeds here, and async switching of tasks will be probably an order of magnitude slower than this slow-down).

https://docs.rs/arc-swap/latest/arc_swap/docs/performance/index.html