|
|
|
|
|
by arghwhat
973 days ago
|
|
The benefit of an RWMutex lies in read-often, write-rare, where serialization of the portion under the read lock would significantly limit throughput (i.e., the read portion takes a while and overlaps significantly with other readers). Whether atomics are applicable depend heavily on the structures and what you are doing under read lock. Atomics are good for reading primitives or pointers that get swapped whole, but not very useful for reason complex structures or traversing arrays/maps. Lock-free atomic structures exist, but are also often slower than their non-atomic counterparts. Rather than making generic statements about what is slow and what is best, profile, profile, profile! |
|