MADNESS
0.10.1
|
Remote reference counter. More...
#include <worldref.h>
Public Member Functions | |
RemoteCounter () | |
RemoteCounter (const RemoteCounter &other) | |
template<typename T > | |
RemoteCounter (World &w, const std::shared_ptr< T > &p) | |
~RemoteCounter () | |
bool | empty () const |
template<typename T > | |
const std::shared_ptr< T > & | get_shared () const |
World & | get_world () const |
WorldPtr< implT >::worldidT | get_worldid () const |
bool | has_owner () const |
bool | is_local () const |
RemoteCounter & | operator= (const RemoteCounter &other) |
ProcessID | owner () const |
void | swap (RemoteCounter &other) |
bool | unique () const |
long | use_count () const |
Counter accessor. More... | |
Private Types | |
typedef RemoteCounterBase | implT |
typedef ConcurrentHashMap< void *, WorldPtr< implT > > | pimpl_mapT |
Private Member Functions | |
RemoteCounter (const WorldPtr< implT > &p) | |
void | destroy () |
Clean-up the implementation object. More... | |
template<typename Archive > | |
void | load_ (const Archive &ar) |
template<typename Archive > | |
void | store_ (const Archive &ar) const |
Static Private Member Functions | |
template<typename T > | |
static WorldPtr< implT > | register_ptr_ (World &w, const std::shared_ptr< T > &p) |
Register a local shared pointer. More... | |
static void | unregister_ptr_ (void *key) |
Unregister a local shared pointer reference. More... | |
Private Attributes | |
WorldPtr< implT > | pimpl_ |
Pointer to the shared counter implementation object. More... | |
Static Private Attributes | |
static pimpl_mapT | pimpl_map_ |
Friends | |
template<typename , typename , typename > | |
struct | archive::ArchiveLoadImpl |
template<typename , typename , typename > | |
struct | archive::ArchiveStoreImpl |
Remote reference counter.
Automatically counts local and remote references to an object. The reference count is incremented when the object is copied locally or serialized as part of communication.
|
private |
|
private |
|
inline |
Referenced by load_().
|
inline |
References pimpl_.
|
inlineexplicit |
|
inline |
References destroy().
|
inlineprivate |
Clean-up the implementation object.
Here we check that the pimpl has been initialized, and if so, we release the current reference. If the count drops to zero, then this is the last reference to the pimpl and it should be deleted.
References pimpl_, madness::print(), and unregister_ptr_().
Referenced by ~RemoteCounter(), and operator=().
|
inline |
References pimpl_.
Referenced by madness::RemoteReference< T >::operator bool().
|
inline |
Referenced by madness::RemoteReference< T >::get_shared().
|
inline |
References pimpl_.
Referenced by madness::RemoteReference< T >::get_world().
References pimpl_.
Referenced by madness::detail::operator<<().
|
inline |
References pimpl_.
Referenced by madness::RemoteReference< T >::reset().
|
inline |
|
inlineprivate |
References RemoteCounter(), p(), pimpl_, and madness::print().
|
inline |
|
inline |
References pimpl_.
Referenced by madness::detail::operator<<(), and madness::RemoteReference< T >::owner().
|
inlinestaticprivate |
Register a local shared pointer.
This function will first search the local pointer register for the shared pointer p
. If found the pimpl for that pointer will be returned. Otherwise a new pimpl will be created and returned.
T | The shared pointer type to register |
w | The world where the pointer lives |
p | The shared pointer to register |
std::bad_alloc | If pimpl allocation fails. |
madness::MadnessException | If pointer cannot be inserted into the pointer registration map. |
References madness::ConcurrentHashMap< keyT, valueT, hashfunT >::insert(), p(), pimpl_map_, madness::print(), and w().
|
inlineprivate |
References pimpl_, and madness::print().
|
inline |
References pimpl_, and madness::detail::swap().
Referenced by madness::detail::swap().
|
inline |
References use_count().
Referenced by madness::RemoteReference< T >::unique().
|
inlinestaticprivate |
Unregister a local shared pointer reference.
key | The key of the RemoteReference object to be unregistered. |
MadnessException | If key is not found in the pointer map. |
References MADNESS_EXCEPTION, pimpl_map_, and madness::ConcurrentHashMap< keyT, valueT, hashfunT >::try_erase().
Referenced by destroy().
|
inline |
Counter accessor.
none |
References pimpl_.
Referenced by madness::detail::operator<<(), unique(), and madness::RemoteReference< T >::use_count().
|
friend |
|
friend |
Pointer to the shared counter implementation object.
Referenced by RemoteCounter(), destroy(), empty(), get_shared(), get_world(), get_worldid(), has_owner(), is_local(), load_(), operator=(), owner(), store_(), swap(), and use_count().
|
staticprivate |
A map of currently registered implementation objects. The key is it's referenced pointer.
Referenced by register_ptr_(), and unregister_ptr_().