|
Ref * | pref_ () const noexcept |
| A pointer to global reference struct.
|
|
Refcnt | refcnt_ () const noexcept |
|
Ref * | scan_ () const noexcept |
|
Ref * | reserve_scan_ (Refcnt *) const noexcept |
|
void | leave_scan_ (Ref *) const noexcept |
|
template<bool NOSWAP> |
bool | compareAndSwap_ (local_shared_ptr< T > &oldvalue, const local_shared_ptr< T > &newvalue) noexcept |
|
| local_shared_ptr (atomic< uintptr_t > *y) |
|
| local_shared_ptr (atomic< uintptr_t > *y, D deleter) |
|
| local_shared_ptr (const atomic_shared_ptr< T > &t) noexcept |
|
| local_shared_ptr (const atomic_shared_ptr< atomic< uintptr_t > > &y) |
|
| local_shared_ptr (const local_shared_ptr< T, reflocal_var_t > &t) noexcept |
|
| local_shared_ptr (const local_shared_ptr< atomic< uintptr_t >, Z > &y) noexcept |
|
| local_shared_ptr (local_shared_ptr< T, reflocal_var_t > &&t) noexcept |
|
| local_shared_ptr (local_shared_ptr< atomic< uintptr_t >, Z > &&y) noexcept |
|
local_shared_ptr & | operator= (const local_shared_ptr &t) noexcept |
|
local_shared_ptr & | operator= (const local_shared_ptr< atomic< uintptr_t >, Z > &y) noexcept |
|
local_shared_ptr & | operator= (local_shared_ptr &&t) noexcept |
|
local_shared_ptr & | operator= (local_shared_ptr< atomic< uintptr_t >, Z > &&y) noexcept |
|
local_shared_ptr & | operator= (const atomic_shared_ptr< T > &t) noexcept |
|
local_shared_ptr & | operator= (const atomic_shared_ptr< atomic< uintptr_t > > &y) noexcept |
|
void | swap (local_shared_ptr &x) noexcept |
|
void | swap (atomic_shared_ptr< T > &x) noexcept |
|
void | reset () noexcept |
| The pointer held by this instance is reset to null pointer.
|
|
void | reset (atomic< uintptr_t > *y) |
| The pointer held by this instance is reset with a pointer y.
|
|
void | reset (atomic< uintptr_t > *y, D deleter) |
|
T * | get () noexcept |
|
const T * | get () const noexcept |
|
T & | operator* () noexcept |
|
const T & | operator* () const noexcept |
|
T * | operator-> () noexcept |
|
const T * | operator-> () const noexcept |
|
bool | operator! () const noexcept |
|
| operator bool () const noexcept |
|
bool | operator== (const local_shared_ptr< atomic< uintptr_t >, Z > &x) const noexcept |
|
bool | operator== (const atomic_shared_ptr< atomic< uintptr_t > > &x) const noexcept |
|
bool | operator!= (const local_shared_ptr< atomic< uintptr_t >, Z > &x) const noexcept |
|
bool | operator!= (const atomic_shared_ptr< atomic< uintptr_t > > &x) const noexcept |
|
int | use_count () const noexcept |
|
bool | unique () const noexcept |
|
Ref * | pref_ () const noexcept |
| A pointer to global reference struct.
|
|
template<typename X>
class atomic_shared_ptr< X >
This is an atomic variant of std::shared_ptr, and can be shared by atomic and lock-free means.
.
atomic_shared_ptr can be shared among threads by the use of operator=(target), swap(target). An instance of atomic_shared_ptr<T> holds:
a) a pointer to atomic_shared_ptr_gref_<T>, which is a struct. consisting of a pointer to a T-type object and a global reference counter.
b) a local (temporary) reference counter, which is embedded in the above pointer by using several LSBs that should be usually zero.
The values of a) and b), m_ref, are atomically handled with CAS machine codes. The purpose of b) the local reference counter is to tell the "observation" to the shared target before increasing the global reference counter. This process is implemented in reserve_scan_().
A function leave_scan_() tries to decrease the local counter first. When it fails, the global counter is decreased.
To swap the pointer and local reference counter (which will be reset to zero), the setter must adds the local counting to the global counter before swapping.
- See Also
- atomic_unique_ptr, local_shared_ptr, atomic_shared_ptr_test.cpp.
Definition at line 84 of file atomic_smart_ptr.h.