proxygen
|
#include <CoreCachedSharedPtr.h>
Classes | |
struct | Slots |
Public Member Functions | |
AtomicCoreCachedSharedPtr (const std::shared_ptr< T > &p=nullptr) | |
~AtomicCoreCachedSharedPtr () | |
void | reset (const std::shared_ptr< T > &p=nullptr) |
std::shared_ptr< T > | get () const |
Private Types | |
using | Holder = std::shared_ptr< T > |
Private Attributes | |
std::atomic< Slots * > | slots_ {nullptr} |
This class creates core-local caches for a given shared_ptr, to mitigate contention when acquiring/releasing it.
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.
Definition at line 100 of file CoreCachedSharedPtr.h.
|
private |
Definition at line 142 of file CoreCachedSharedPtr.h.
|
inlineexplicit |
Definition at line 102 of file CoreCachedSharedPtr.h.
References folly::CoreCachedSharedPtr< T, kNumSlots >::reset().
|
inline |
Definition at line 106 of file CoreCachedSharedPtr.h.
References folly::CoreCachedSharedPtr< T, kNumSlots >::slots_.
|
inline |
Definition at line 132 of file CoreCachedSharedPtr.h.
References folly::AccessSpreader< Atom >::current(), and folly::CoreCachedSharedPtr< T, kNumSlots >::slots_.
|
inline |
Definition at line 115 of file CoreCachedSharedPtr.h.
References folly::enumerate(), and folly::CoreCachedSharedPtr< T, kNumSlots >::slots_.
|
private |
Definition at line 146 of file CoreCachedSharedPtr.h.