MADNESS 0.10.1
|
A future is a possibly yet unevaluated value. More...
#include <future.h>
Classes | |
class | dddd |
Public Types | |
typedef RemoteReference< FutureImpl< T > > | remote_refT |
Public Member Functions | |
Future () | |
Makes an unassigned future. | |
Future (const archive::BufferInputArchive &input_arch) | |
Makes an assigned future from an input archive. | |
Future (const Future< T > &other) | |
Shallow copy constructor. | |
Future (const remote_refT &remote_ref) | |
Makes a future wrapping a remote reference. | |
Future (const T &t) | |
Makes an assigned future. | |
~Future () | |
Destructor. | |
T & | get (bool dowork=true) & |
Gets the value, waiting if necessary. | |
T | get (bool dowork=true) && |
Gets the value, waiting if necessary. | |
const T & | get (bool dowork=true) const & |
Gets the value, waiting if necessary. | |
bool | is_default_initialized () const |
Check if the future is default initialized. | |
bool | is_local () const |
Checks the future remoteness trait. | |
bool | is_remote () const |
Checks the future remoteness trait. | |
operator const T & () const & | |
Same as get() const& . | |
operator T () && | |
An rvalue analog of get() . | |
operator T& () & | |
Same as get()& . | |
Future< T > & | operator= (const Future< T > &other) |
Shallow assignment operator. | |
bool | probe () const |
Check whether this future has been assigned. | |
void | register_callback (CallbackInterface *callback) |
Registers an object to be called when future is assigned. | |
remote_refT | remote_ref (World &world) const |
Returns a structure used to pass references to another process. | |
void | set (const archive::BufferInputArchive &input_arch) |
Assigns the value. | |
void | set (const Future< T > &other) |
A.set(B) , where A and B are futures ensures A has/will have the same value as B . | |
void | set (const T &value) |
Assigns the value. | |
void | set (T &&value) |
Assigns the value. | |
Static Public Member Functions | |
static const Future< T > | default_initializer () |
See "Gotchas" on Futures about why this exists and how to use it. | |
Private Member Functions | |
Future (const dddd &blah) | |
Private Attributes | |
char | buffer [sizeof(T)] |
Buffer to hold a single T object. | |
std::shared_ptr< FutureImpl< T > > | f |
Pointer to the implementation object. | |
T *const | value |
Pointer to buffer when it holds a T object. | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const Future< T > &f) |
Human readable printing of a Future to a stream. | |
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 pointer is never made. The point of this is to eliminate the two malloc
s that must be peformed for every new shared_ptr
.
T | The type of future. |
typedef RemoteReference< FutureImpl<T> > madness::Future< T >::remote_refT |
|
inlineexplicitprivate |
|
inline |
Makes an unassigned future.
|
inlineexplicit |
|
inlineexplicit |
Makes a future wrapping a remote reference.
[in] | remote_ref | The remote reference. |
|
inlineexplicit |
Makes an assigned future from an input archive.
[in] | input_arch | The input archive. |
|
inline |
Shallow copy constructor.
[in] | other | The future to copy. |
References madness::Future< T >::f, and madness::Future< T >::is_default_initialized().
|
inline |
Destructor.
References madness::Future< T >::value.
|
inlinestatic |
See "Gotchas" on Futures about why this exists and how to use it.
Referenced by madness::future_vector_factory(), and madness::WorldGopInterface::reduce_internal().
|
inline |
Gets the value, waiting if necessary.
dowork | If true (default) and the future is not ready this thread will execute other tasks while waiting |
dowork=true
from a callstack containing a running MADNESS task already, hence must use dowork=false
when need to call from within a task this->is_local()
References madness::Future< T >::f, madness::Future< T >::is_local(), MADNESS_CHECK, and madness::Future< T >::value.
Referenced by madness::WorldGopInterface::bcast_internal(), madness::WorldGopInterface::bcast_internal(), madness::Derivative< T, NDIM >::do_diff2b(), madness::MacroTaskQ::get_scheduled_task_number(), main(), madness::WorldGopInterface::DelayedSend< keyT, valueT >::notify(), madness::Future< bool >::operator bool(), madness::Future< bool >::operator bool &(), madness::Future< bool >::operator const bool &(), madness::Future< std::vector< Future< T > > >::operator const vectorT &(), madness::Future< std::vector< Future< T > > >::operator vectorT &(), madness::LoadBalanceDeux< NDIM >::print_tree(), madness::WorldGopInterface::reduce_result_task(), madness::WorldGopInterface::send_internal(), madness::Future< T >::set(), test10(), test5(), test9(), and madness::FunctionImpl< T, NDIM >::truncate_spawn().
|
inline |
Gets the value, waiting if necessary.
dowork | If true (default) and the future is not ready this thread will execute other tasks while waiting |
dowork=true
from a callstack containing a running MADNESS task already, hence must use dowork=false
when need to call from within a task this->is_local()
References madness::Future< T >::f, madness::Future< T >::is_local(), MADNESS_CHECK, and madness::Future< T >::value.
|
inline |
Gets the value, waiting if necessary.
dowork | If true (default) and the future is not ready this thread will execute other tasks while waiting |
dowork=true
from a callstack containing a running MADNESS task already, hence must use dowork=false
when need to call from within a task this->is_local()
References madness::Future< T >::f, madness::Future< T >::is_local(), MADNESS_CHECK, and madness::Future< T >::value.
|
inline |
Check if the future is default initialized.
default_initializer()
; false otherwise. References madness::Future< T >::f, and madness::Future< T >::value.
Referenced by madness::Future< T >::Future().
|
inline |
Checks the future remoteness trait.
References madness::Future< T >::f, and madness::Future< T >::value.
Referenced by madness::Future< T >::get(), madness::Future< T >::get(), madness::Future< T >::get(), and madness::Future< T >::is_remote().
|
inline |
Checks the future remoteness trait.
References madness::Future< T >::is_local().
|
inline |
Same as get() const&
.
|
inline |
An rvalue analog of get()
.
|
inline |
Same as get()&
.
|
inline |
Shallow assignment operator.
[in] | other | The future to copy. |
References madness::Future< T >::f, MADNESS_ASSERT, madness::Future< T >::probe(), madness::Future< T >::set(), and madness::Future< T >::value.
|
inline |
Check whether this future has been assigned.
References madness::Future< T >::f, and madness::Future< T >::value.
Referenced by madness::WorldGopInterface::bcast(), madness::WorldGopInterface::bcast(), madness::WorldGopInterface::bcast_internal(), madness::WorldGopInterface::bcast_internal(), madness::TaskFn< fnT, arg1T, arg2T, arg3T, arg4T, arg5T, arg6T, arg7T, arg8T, arg9T >::check_dependency(), madness::TaskFn< fnT, arg1T, arg2T, arg3T, arg4T, arg5T, arg6T, arg7T, arg8T, arg9T >::check_dependency(), madness::WorldGopInterface::lazy_sync_internal(), madness::WorldGopInterface::DelayedSend< keyT, valueT >::notify(), madness::Future< T >::operator=(), madness::Future< T >::register_callback(), madness::Future< T >::remote_ref(), madness::WorldGopInterface::send_internal(), madness::Future< T >::set(), and test5().
|
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.
[in] | callback | The callback to be invoked. |
References madness::Future< T >::f, MADNESS_ASSERT, madness::CallbackInterface::notify(), and madness::Future< T >::probe().
Referenced by madness::TaskFn< fnT, arg1T, arg2T, arg3T, arg4T, arg5T, arg6T, arg7T, arg8T, arg9T >::check_dependency(), and madness::TaskFn< fnT, arg1T, arg2T, arg3T, arg4T, arg5T, arg6T, arg7T, arg8T, arg9T >::check_dependency().
|
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; that is, 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).
[in,out] | world | The communication world. |
References madness::Future< T >::f, MADNESS_ASSERT, and madness::Future< T >::probe().
Referenced by madness::Function< T, NDIM >::eval(), madness::Function< T, NDIM >::evaldepthpt(), madness::Function< T, NDIM >::evalR(), madness::WorldContainerImpl< keyT, valueT, hashfunT >::find(), madness::FunctionImpl< T, NDIM >::find_me(), madness::DerivativeBase< T, NDIM >::find_neighbor(), and madness::FunctionImpl< T, NDIM >::project_out2().
|
inline |
Assigns the value.
The value can only be set once.
[in] | input_arch | Description needed. |
References madness::Future< T >::f, and MADNESS_CHECK.
|
inline |
A.set(B)
, where A
and 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, 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).
References madness::Future< T >::f, fred(), madness::Future< T >::get(), MADNESS_ASSERT, madness::Future< T >::probe(), and madness::Future< T >::set().
Referenced by madness::FunctionImpl< T, NDIM >::eval(), madness::FunctionImpl< T, NDIM >::evaldepthpt(), madness::FunctionImpl< T, NDIM >::evalR(), madness::detail::DistCache< keyT >::get_cache_value(), main(), madness::Future< T >::operator=(), madness::detail::ForEachRootTask< rangeT, opT >::run(), madness::detail::run_function(), madness::detail::run_function(), madness::detail::run_function(), madness::detail::run_function(), madness::detail::run_function(), madness::detail::run_function(), madness::detail::run_function(), madness::detail::run_function(), madness::detail::run_function(), madness::detail::run_function(), madness::Future< T >::set(), madness::FunctionImpl< T, NDIM >::sock_it_to_me(), madness::FunctionImpl< T, NDIM >::sock_it_to_me_too(), test5(), and test9().
|
inline |
Assigns the value.
The value can only be set once.
[in] | value | The value to be assigned. |
References madness::Future< T >::f, MADNESS_CHECK, and madness::Future< T >::value.
|
inline |
Assigns the value.
The value can only be set once.
[in] | value | The value to be assigned. |
References madness::Future< T >::f, MADNESS_CHECK, and madness::Future< T >::value.
|
friend |
Human readable printing of a Future
to a stream.
Stream output operator for a future.
T | The type of future. |
[in,out] | out | The output stream. |
[in] | f | The future. |
T | Description needed. |
[in,out] | The | output stream. |
[in] | f | The future to be output. |
|
private |
Buffer to hold a single T
object.
|
private |
Pointer to the implementation object.
Referenced by madness::Future< T >::Future(), madness::Future< T >::get(), madness::Future< T >::get(), madness::Future< T >::get(), madness::Future< T >::is_default_initialized(), madness::Future< T >::is_local(), madness::Future< T >::operator=(), madness::Future< T >::probe(), madness::Future< T >::register_callback(), madness::Future< T >::remote_ref(), madness::Future< T >::set(), madness::Future< T >::set(), madness::Future< T >::set(), and madness::Future< T >::set().
|
private |
Pointer to buffer when it holds a T
object.
Referenced by madness::Future< T >::~Future(), madness::Future< T >::get(), madness::Future< T >::get(), madness::Future< T >::get(), madness::Future< T >::is_default_initialized(), madness::Future< T >::is_local(), madness::Future< T >::operator=(), madness::Future< T >::probe(), madness::Future< T >::set(), and madness::Future< T >::set().