|
MADNESS 0.10.1
|
Base class for WorldObject. More...
#include <world_object.h>


Public Member Functions | |
| virtual | ~WorldObjectBase () |
| World & | get_world () const |
| World & | get_world_noexcept () const noexcept |
| Get the world to which this object belongs, without risking a throw. | |
| const uniqueidT & | id () const |
| Returns the globally unique object ID. | |
| bool | world_is_alive () const noexcept |
| Reports whether the world to which this object belongs still exists. | |
Protected Member Functions | |
| WorldObjectBase (const WorldObjectBase &other) | |
| Copy constructor; produces an unregistered object. | |
| WorldObjectBase (World &w) | |
| Construct a new WorldObjectBase. | |
| World & | get_world_unchecked () const noexcept |
| Unchecked access to the memoized world reference. | |
| template<typename DerivedT > | |
| void | register_self (DerivedT *this_ptr) |
| Registers this object with its world, making it globally addressable. | |
Private Attributes | |
| uniqueidT | objid |
Unique object ID; null until register_self() has been called. | |
| World & | world |
| Memoized reference to the world to which this object belongs. | |
| World::liveness_handleT | world_liveness |
Reports whether world is still alive. | |
Base class for WorldObject.
Holds the parts of a WorldObject that do not depend on the derived class: the unique object ID and the World the object belongs to, the latter accessible to the derived class via get_world(). Should not be used directly, but rather through WorldObject<Derived>.
|
inlineexplicitprotected |
Construct a new WorldObjectBase.
Protected, should only be called from the WorldObject constructor.
w; the derived WorldObject must call register_self() to do that, once its own members have been initialized. | [in] | w | The world to which this object belongs. |
|
inlineprotected |
Copy constructor; produces an unregistered object.
Exists solely so that the derived WorldObject remains copy constructible (which pre-C++17 is needed to permit RVO), never to produce a usable object. The copy aliases the world of other but deliberately does not copy its ID and is not registered with the world: were the copy destroyed it would otherwise unregister other, evicting a live object from the world's ID maps.
| [in] | other | The object whose world is to be aliased. |
|
inlinevirtual |
|
inline |
Get the world to which this object belongs.
get_world() is called in hot loops. MADNESS_CHECK, so that the use-after-free is also caught in release builds (where MADNESS_ASSERT compiles away), once the cost of the liveness load in hot loops has been measured. References MADNESS_ASSERT, world, and world_is_alive().
Referenced by madness::SeparatedConvolution< Q, NDIM >::combine(), madness::ScalarResultImpl< T >::gaxpy(), madness::ScalarResultImpl< T >::get(), madness::BatchTransport::on_reply(), madness::BatchTransport::on_trigger(), Foo::ping(), Foo::ping_am(), Foo::pong(), Foo::pong_am(), madness::SeparatedConvolution< Q, NDIM >::print_timer(), Array::read(), madness::WorldContainerImpl< keyT, valueT, hashfunT >::redistribute_phase2(), madness::WorldContainerImpl< keyT, valueT, hashfunT >::replicate(), madness::WorldContainerImpl< keyT, valueT, hashfunT >::replicate_on_hosts(), madness::BatchTransport::request(), madness::WorldContainerImpl< keyT, valueT, hashfunT >::reset_pmap_to_local(), madness::SeparatedConvolution< Q, NDIM >::reset_timer(), madness::WorldObject< Derived >::send_am(), madness::WorldObject< Derived >::send_task(), madness::WorldObject< Derived >::task(), madness::WorldObject< Derived >::task(), madness::WorldObject< Derived >::task(), madness::WorldObject< Derived >::task(), madness::WorldObject< Derived >::task(), madness::WorldObject< Derived >::task(), madness::WorldObject< Derived >::task(), madness::WorldObject< Derived >::task(), madness::WorldObject< Derived >::task(), madness::WorldObject< Derived >::task(), TestFutureForwarding::test(), and Array::write().
|
inlinenoexcept |
Get the world to which this object belongs, without risking a throw.
Same as get_world(), except the memoized reference is validated with MADNESS_ASSERT_NOEXCEPT, which aborts rather than throws. Use this from destructors and other noexcept contexts, where a throwing MADNESS_ASSERT would call std::terminate and thereby discard the diagnostic.
References MADNESS_ASSERT_NOEXCEPT, world, and world_is_alive().
Referenced by madness::WorldObject< Derived >::~WorldObject().
|
inlineprotectednoexcept |
Unchecked access to the memoized world reference.
world_is_alive() check). References world.
|
inline |
Returns the globally unique object ID.
References objid.
Referenced by madness::archive::ArchiveStoreImpl< Archive, const DerivativeBase< T, NDIM > * >::store(), madness::archive::ArchiveStoreImpl< Archive, const FunctionImpl< T, NDIM > * >::store(), madness::archive::ArchiveStoreImpl< Archive, FunctionImpl< T, NDIM > * >::store(), madness::archive::ArchiveStoreImpl< BufferOutputArchive, const WorldObject< Derived > * >::store(), and madness::archive::ArchiveStoreImpl< BufferOutputArchive, WorldObject< Derived > * >::store().
Registers this object with its world, making it globally addressable.
WorldObject constructor after all of its members have been initialized: registration publishes this object to the active-message handlers running on the runtime threads, which read those members (see WorldObject::is_ready()). | DerivedT | The derived class being registered. |
| [in] | this_ptr | Pointer to the derived object being registered. |
References MADNESS_ASSERT, madness::nonlinear_vector_solver(), objid, madness::World::register_ptr(), and world.
Referenced by madness::WorldObject< Derived >::WorldObject().
|
inlinenoexcept |
Reports whether the world to which this object belongs still exists.
A WorldObject must not outlive its World, but it happens; this makes the (otherwise silent) use-after-free detectable.
References world_liveness.
Referenced by madness::WorldObject< Derived >::~WorldObject(), ~WorldObjectBase(), get_world(), and get_world_noexcept().
|
private |
Unique object ID; null until register_self() has been called.
Referenced by ~WorldObjectBase(), id(), and register_self().
|
private |
Memoized reference to the world to which this object belongs.
Referenced by madness::BinSorter< T, inserterT >::BinSorter(), Foo::Foo(), madness::SeparatedConvolution< Q, NDIM >::SeparatedConvolution(), madness::WorldObject< Derived >::~WorldObject(), ~WorldObjectBase(), madness::WorldContainerImpl< keyT, valueT, hashfunT >::do_replicate(), get_world(), get_world_noexcept(), get_world_unchecked(), Array::read(), register_self(), madness::WorldContainerImpl< keyT, valueT, hashfunT >::replicate(), madness::WorldContainerImpl< keyT, valueT, hashfunT >::replicate_on_hosts(), madness::WorldObject< Derived >::send_am(), madness::WorldObject< Derived >::send_task(), madness::MacroTaskQ::set_pmap(), and Array::write().
|
private |
Reports whether world is still alive.
Referenced by world_is_alive().