This class creates core-local caches for a given shared_ptr, to mitigate contention when acquiring/releasing it.
Declared in <folly/concurrency/CoreCachedSharedPtr.h>
template<
class T,
size_t kMaxSlots = kCoreCachedSharedPtrDefaultMaxSlots>
class AtomicCoreCachedSharedPtr;
All methods are threadsafe. Hazard pointers are used to avoid use-after-free for concurrent reset() and get() operations.
Concurrent reset()s are sequenced with respect to each other: the sharded shared_ptrs will always all be set to the same value. get()s will never see a newer pointer on one core, and an older pointer on another after a subsequent thread migration.
| Name | Description |
|---|---|
AtomicCoreCachedSharedPtr [constructor] | Constructors |
~AtomicCoreCachedSharedPtr [destructor] | Destroys the pointer and releases the core-local caches. |
operator= [deleted] | Move assignment is deleted. |
get | Returns the shared pointer cached for the current core. |
reset | Atomically replaces the held pointer, repopulating the core-local caches. |