MADNESS
version 0.9
|
A future is a possibly yet unevaluated value. More...
#include <ref.h>
Public Types | |
typedef RemoteReference < FutureImpl< T > > | remote_refT |
Public Member Functions | |
Future () | |
Makes an unassigned future. More... | |
Future (const T &t) | |
Makes an assigned future. More... | |
Future (const remote_refT &remote_ref) | |
Makes a future wrapping a remote reference. More... | |
Future (const archive::BufferInputArchive &input_arch) | |
Makes an assigned future from an input archive. More... | |
Future (const Future< T > &other) | |
Copy constructor is shallow. More... | |
~Future () | |
bool | is_default_initialized () const |
Default initialized query. More... | |
Future< T > & | operator= (const Future< T > &other) |
Assignment future = future makes a shallow copy just like copy constructor. More... | |
void | set (const Future< T > &other) |
A.set(B) where A & B are futures ensures A has/will have the same value as B. More... | |
void | set (const T &value) |
Assigns the value ... it can only be set ONCE. More... | |
void | set (const archive::BufferInputArchive &input_arch) |
Assigns the value ... it can only be set ONCE. More... | |
T & | get () |
Gets the value, waiting if necessary (error if not a local future) More... | |
const T & | get () const |
Gets the value, waiting if necessary (error if not a local future) More... | |
bool | probe () const |
Query the whether this future has been assigned. More... | |
operator T & () | |
Same as get() More... | |
operator const T & () const | |
Same as get() const. More... | |
remote_refT | remote_ref (World &world) const |
Returns a structure used to pass references to another process. More... | |
bool | is_local () const |
bool | is_remote () const |
void | register_callback (CallbackInterface *callback) |
Registers an object to be called when future is assigned. More... | |
Static Public Member Functions | |
static const Future< T > | default_initializer () |
See Gotchas on the documentation mainpage about why this exists and how to use it. More... | |
Friends | |
std::ostream & | operator (std::ostream &out, const Future< T > &f) |
A future is a possibly yet unevaluated value.
Uses delegation to FutureImpl to provide desired copy/assignment semantics as well as safe reference counting for remote futures.
Since we are using Futures a lot to store local values coming from containers and inside task wrappers for messages, we included in this class a value. If a future is assigned before a copy/remote-reference is taken, the shared ptr is never made. The point of this is to eliminate the two mallocs that must be peformed for every new shared_ptr.
typedef RemoteReference< FutureImpl<T> > madness::Future< T >::remote_refT |
|
inline |
Makes an unassigned future.
|
inlineexplicit |
Makes an assigned future.
|
inlineexplicit |
Makes a future wrapping a remote reference.
|
inlineexplicit |
Makes an assigned future from an input archive.
|
inline |
Copy constructor is shallow.
|
inline |
|
inlinestatic |
See Gotchas on the documentation mainpage about why this exists and how to use it.
Referenced by madness::future_vector_factory().
|
inline |
Gets the value, waiting if necessary (error if not a local future)
Referenced by madness::FunctionImpl< T, NDIM >::coeffs_for_jun(), madness::FunctionImpl< T, NDIM >::eval(), madness::FunctionImpl< T, NDIM >::eval_local_only(), madness::FunctionImpl< T, NDIM >::evaldepthpt(), madness::FunctionImpl< T, NDIM >::evalR(), and madness::LoadBalanceDeux< NDIM >::print_tree().
|
inline |
Gets the value, waiting if necessary (error if not a local future)
|
inline |
Default initialized query.
true
if this future was constructed with default_initializer()
, otherwise false
.
|
inline |
Referenced by madness::Future< bool >::is_remote().
|
inline |
|
inline |
Same as get() const.
|
inline |
Same as get()
|
inline |
Assignment future = future makes a shallow copy just like copy constructor.
|
inline |
Query the whether this future has been assigned.
true
if the future has been assigned, otherwise false
Referenced by madness::WorldGopInterface::bcast(), madness::Future< bool >::operator=(), madness::Future< bool >::register_callback(), madness::Future< bool >::remote_ref(), and madness::detail::DistCache< keyT >::set_cache_value().
|
inline |
Registers an object to be called when future is assigned.
Callbacks are invoked in the order registered. If the future is already assigned the callback is immediately invoked.
|
inline |
Returns a structure used to pass references to another process.
This is used for passing pointers/references to another process. To make remote references completely safe, the RemoteReference increments the internal reference count of the Future. The counter is decremented by either assigning to the remote Future or its destructor if it is never assigned. The remote Future is ONLY useful for setting the future. It will NOT be notified if the value is set elsewhere.
If this is already a reference to a remote future, the actual remote reference is returned ... i.e., not a a reference to the local future. Therefore, the local future will not be notified when the result is set (i.e., the communication is short circuited).
Referenced by madness::FunctionImpl< T, NDIM >::coeffs_for_jun(), madness::Function< double, 6 >::eval(), madness::Function< double, 6 >::evaldepthpt(), madness::Function< double, 6 >::evalR(), madness::WorldContainerImpl< keyT, valueT, hashfunT >::find(), madness::FunctionImpl< T, NDIM >::find_me(), madness::DerivativeBase< T, NDIM >::find_neighbor(), and madness::FunctionImpl< Q, NDIM >::project_out2().
|
inline |
A.set(B) where A & B are futures ensures A has/will have the same value as B.
An exception is thrown if A is already assigned since a Future is a single assignment variable. We don't yet track multiple assignments from unassigned futures.
If B is already assigned, this is the same as A.set(B.get()) which sets A to the value of B.
If B has not yet been assigned, the behavior is to ensure that when B is assigned that both A and B will be assigned and have the same value (though they may/may not refer to the same underlying copy of the data and indeed may even be in different processes).
Referenced by madness::detail::DistCache< keyT >::get_cache_value(), madness::Future< bool >::operator=(), madness::detail::run_function(), madness::Future< bool >::set(), madness::detail::DistCache< keyT >::set_cache_value(), madness::FunctionImpl< T, NDIM >::sock_it_to_me(), and madness::FunctionImpl< T, NDIM >::sock_it_to_me_too().
|
inline |
Assigns the value ... it can only be set ONCE.
|
inline |
Assigns the value ... it can only be set ONCE.
|
friend |