Legion Runtime
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Legion::Future Class Reference

#include <legion.h>

Inheritance diagram for Legion::Future:
Legion::Unserializable< Future >

Public Member Functions

 Future (const Future &f)
 
 Future (Future &&f)
 
bool operator== (const Future &f) const
 
bool operator< (const Future &f) const
 
Futureoperator= (const Future &f)
 
Futureoperator= (Future &&f)
 
template<typename T >
get_result (bool silence_warnings=false, const char *warning_string=NULL) const
 
void get_void_result (bool silence_warnings=false, const char *warning_string=NULL) const
 
bool is_empty (bool block=false, bool silence_warnings=false, const char *warning_string=NULL) const
 
bool is_ready (bool subscribe=false) const
 
template<typename T >
const T & get_reference (bool silence_warnings=false, const char *warning_string=NULL) const
 
const void * get_untyped_pointer (bool silence_warnings=false, const char *warning_string=NULL) const
 
size_t get_untyped_size (void) const
 
template<typename T >
get (void)
 
bool valid (void) const
 
void wait (void) const
 
- Public Member Functions inherited from Legion::Unserializable< Future >
size_t legion_buffer_size (void)
 
size_t legion_serialize (void *buffer)
 
size_t legion_deserialize (const void *buffer)
 

Static Public Member Functions

template<typename T >
static Future from_value (Runtime *rt, const T &value)
 
static Future from_untyped_pointer (Runtime *rt, const void *buffer, size_t bytes)
 

Protected Member Functions

FRIEND_ALL_RUNTIME_CLASSES Future (Internal::FutureImpl *impl, bool need_reference=true)
 

Detailed Description

Futures are the objects returned from asynchronous task launches. Applications can wait on futures to get their values, pass futures as arguments and preconditions to other tasks, or use them to create predicates if they are boolean futures. Futures are lightweight handles that can be passed by value or stored in data structures. However, futures should not escape the context in which they are created as the runtime garbage collects them after the enclosing task context completes execution.

Since futures can be the result of predicated tasks we also provide a mechanism for checking whether the future contains an empty result. An empty future will be returned for all futures which come from tasks which predicates that resolve to false.

Member Function Documentation

static Future Legion::Future::from_untyped_pointer ( Runtime rt,
const void *  buffer,
size_t  bytes 
)
inlinestatic

Generates a future from an untyped pointer. No serialization is performed.

template<typename T >
static Future Legion::Future::from_value ( Runtime rt,
const T &  value 
)
inlinestatic

Allow users to generate their own futures. These futures are guaranteed to always have completed and to always have concrete values.

template<typename T >
const T& Legion::Future::get_reference ( bool  silence_warnings = false,
const char *  warning_string = NULL 
) const
inline

Return a const reference to the future. WARNING: these method is unsafe as the underlying buffer containing the future result can be deleted if the Future handle is lost even a reference to the underlying buffer is maitained. This scenario can lead to seg-faults. Use at your own risk. Note also that this call will not properly deserialize buffers that were serialized with a 'legion_serialize' method.

Parameters
silence_warningssilence any warnings for this blocking call
warning_stringa string to be reported with the warning
template<typename T >
T Legion::Future::get_result ( bool  silence_warnings = false,
const char *  warning_string = NULL 
) const
inline

Wait on the result of this future. Return the value of the future as the specified template type.

Parameters
silence_warningssilence any warnings for this blocking call
warning_stringa string to be reported with the warning
Returns
the value of the future cast as the template type
const void* Legion::Future::get_untyped_pointer ( bool  silence_warnings = false,
const char *  warning_string = NULL 
) const
inline

Return an untyped pointer to the future result. WARNING: this method is unsafe for the same reasons as get_reference. It also will not deserialize anything serialized with a legion_serialize method.

Parameters
silence_warningssilence any warnings for this blocking call
warning_stringa string to be reported with the warning
size_t Legion::Future::get_untyped_size ( void  ) const

Return the number of bytes contained in the future.

void Legion::Future::get_void_result ( bool  silence_warnings = false,
const char *  warning_string = NULL 
) const

Block until the future completes.

Parameters
silence_warningssilence any warnings for this blocking call
warning_stringa string to be reported with the warning
bool Legion::Future::is_empty ( bool  block = false,
bool  silence_warnings = false,
const char *  warning_string = NULL 
) const

Check to see if the future is empty. The user can specify whether to block and wait for the future to complete first before returning. If the non-blocking version of the call will return true, until the future actually completes.

Parameters
blockindicate whether to block for the result
silence_warningssilence any warnings for this blocking call
warning_stringa string to be reported with the warning
bool Legion::Future::is_ready ( bool  subscribe = false) const

Check to see if the future is ready. This will return true if the future can be used without blocking to wait on the computation that the future represents, otherwise it will return false.

Parameters
subscribeask for the payload to be brought here when ready

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