MADNESS 0.10.1
madness::FutureImpl< void > Class Reference

Specialization of FutureImpl<void> for internal convenience. This does nothing useful! More...

#include <future.h>

Inheritance diagram for madness::FutureImpl< void >:
Collaboration diagram for madness::FutureImpl< void >:

Public Member Functions

 FutureImpl ()
 Constructor that uses a local unassigned value.
virtual ~FutureImpl ()
 Destructor.
void & get (bool dowork=true)
 Gets/forces the value, waiting if necessary.
bool is_local () const
bool probe () const
 Checks if the value has been assigned.
void register_callback (CallbackInterface *callback)
 Registers a function to be invoked when future is assigned.
bool replace_with (FutureImpl< void > *f)
void set (U &&value)
 Sets the value of the future (assignment).

Private Types

typedef Stack< std::shared_ptr< FutureImpl< void > >, MAXCALLBACKS > assignmentT
 Assignment type.
typedef Stack< CallbackInterface *, MAXCALLBACKS > callbackT
 Callback type.

Private Member Functions

void add_to_assignments (const std::shared_ptr< FutureImpl< void > > f)
 Pass by value with implied copy to manage lifetime of f.
void set_assigned (const void &value)
Private Member Functions inherited from madness::Spinlock
 Spinlock (int junk=0)
 Make and initialize a spinlock ... initial state is unlocked.
virtual ~Spinlock ()
void lock () const
 Acquire the spinlock waiting if necessary.
bool try_lock () const
 Try to acquire the spinlock ... return true on success, false on failure.
void unlock () const
 Free a spinlock owned by this thread.

Static Private Member Functions

static void set_handler (const AmArg &arg)
 AM handler for remote set operations.

Private Attributes

std::atomic< bool > assigned
 A flag indicating if the future has been set.
volatile assignmentT assignments
volatile callbackT callbacks
RemoteReference< FutureImpl< void > > remote_ref
 Reference to a remote future pimpl.
volatile void t
 The future data.

Static Private Attributes

static const int MAXCALLBACKS

Friends

class Future< T >
std::ostream & operator<< (std::ostream &out, const Future< void > &f)
 Human readable printing of a Future to a stream.

Detailed Description

Specialization of FutureImpl<void> for internal convenience. This does nothing useful!

Member Typedef Documentation

◆ assignmentT

typedef Stack<std::shared_ptr<FutureImpl<void> >,MAXCALLBACKS> madness::FutureImpl< void >::assignmentT
private

Assignment type.

◆ callbackT

typedef Stack<CallbackInterface*, MAXCALLBACKS> madness::FutureImpl< void >::callbackT
private

Callback type.

Constructor & Destructor Documentation

◆ FutureImpl()

madness::FutureImpl< void >::FutureImpl ( )
inline

Constructor that uses a local unassigned value.

◆ ~FutureImpl()

virtual madness::FutureImpl< void >::~FutureImpl ( )
inlinevirtual

Destructor.

Todo
Perhaps a comment about its behavior.

Member Function Documentation

◆ add_to_assignments()

void madness::FutureImpl< void >::add_to_assignments ( const std::shared_ptr< FutureImpl< void > > f)
inlineprivate

Pass by value with implied copy to manage lifetime of f.

Todo
Description needed.
Parameters
[in]fDescription needed.

◆ get()

void & madness::FutureImpl< void >::get ( bool dowork = true)
inline

Gets/forces the value, waiting if necessary.

Parameters
doworkIf true (default) and the future is not ready this thread will execute other tasks while waiting
Warning
PaRSEC backend does not support dowork=true from a callstack containing a running MADNESS task already, hence must use dowork=false when need to call from within a task
Returns
reference to the contained value
Precondition
this->is_local()

◆ is_local()

bool madness::FutureImpl< void >::is_local ( ) const
inline
Todo
Brief description needed.
Todo
Description needed.
Returns
Description needed.

◆ probe()

bool madness::FutureImpl< void >::probe ( ) const
inline

Checks if the value has been assigned.

Returns
True if the value has been assigned; false otherwise.

◆ register_callback()

void madness::FutureImpl< void >::register_callback ( CallbackInterface * callback)
inline

Registers a function to be invoked when future is assigned.

Callbacks are invoked in the order registered. If the future is already assigned, the callback is immediately invoked.

Todo
Description needed.
Parameters
callbackDescription needed.

◆ replace_with()

bool madness::FutureImpl< void >::replace_with ( FutureImpl< void > * f)
inline
Todo
Brief description needed.
Todo

Is this function needed?

Details needed.

Parameters
fDescription needed.
Returns
Description needed.

◆ set()

void madness::FutureImpl< void >::set ( U && value)
inline

Sets the value of the future (assignment).

Todo
Descriptions needed.
Template Parameters
UDescription needed.
Parameters
[in]valueDescription needed.

◆ set_assigned()

void madness::FutureImpl< void >::set_assigned ( const void & value)
inlineprivate
Todo
Brief description needed.

Invoked locally by set routine after assignment.

Todo
Description needed.
Parameters
[in]valueDescription needed.

◆ set_handler()

void madness::FutureImpl< void >::set_handler ( const AmArg & arg)
inlinestaticprivate

AM handler for remote set operations.

Todo
Description needed.
Parameters
[in]argDescription needed.

◆ Future< T >

friend class Future< void >
friend

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const Future< void > & f )
friend

Human readable printing of a Future to a stream.

Stream output operator for a future.

Template Parameters
TThe type of future.
Parameters
[in,out]outThe output stream.
[in]fThe future.
Returns
The output stream.
Todo
Brief description needed.
Todo
Descriptions needed.
Template Parameters
TDescription needed.
Parameters
[in,out]Theoutput stream.
[in]fThe future to be output.
Returns
The output stream.

References madness::f.

Member Data Documentation

◆ assigned

std::atomic<bool> madness::FutureImpl< void >::assigned
private

A flag indicating if the future has been set.

◆ assignments

volatile assignmentT madness::FutureImpl< void >::assignments
mutableprivate

A stack that stores future objects that are set to the same value as this future, once it has been set.

◆ callbacks

volatile callbackT madness::FutureImpl< void >::callbacks
private

A stack that stores callbacks that are invoked once the future has been assigned.

◆ MAXCALLBACKS

const int madness::FutureImpl< void >::MAXCALLBACKS
staticprivate

The static stack size used for callbacks and future assignment used for small stack size optimizations.

◆ remote_ref

RemoteReference< FutureImpl<void> > madness::FutureImpl< void >::remote_ref
private

Reference to a remote future pimpl.

◆ t

volatile void madness::FutureImpl< void >::t
private

The future data.


The documentation for this class was generated from the following file: