SimGrid  3.16
Versatile Simulation of Distributed Systems
simgrid::kernel::Promise< T > Class Template Reference

Detailed Description

template<class T>
class simgrid::kernel::Promise< T >

Producer side of a simgrid::kernel::Future.

A Promise is connected to some Future and can be used to set its result.

Similar to std::promise

// Create a promise and a future: auto promise = std::make_shared<simgrid::kernel::Promise<T>>(); auto future = promise->get_future();

SIMIX_timer_set(date, [promise] { try { int value = compute_the_value(); if (value < 0) throw std::logic_error("Bad value"); // Whenever the operation is completed, we set the value // for the future: promise.set_value(value); } catch (...) { // If an error occured, we can set an exception which // will be throwed buy future.get(): promise.set_exception(std::current_exception()); } });

// Return the future to the caller: return future;

#include <future.hpp>

Public Member Functions

 Promise ()
 
 Promise (std::shared_ptr< FutureState< T >> state)
 
 Promise (Promise const &)=delete
 
Promiseoperator= (Promise const &)=delete
 
 Promise (Promise &&that)
 
Promiseoperator= (Promise &&that)
 
Future< T > get_future ()
 
void set_value (T value)
 
void set_exception (std::exception_ptr exception)
 
 ~Promise ()
 
 Promise ()
 
 Promise (std::shared_ptr< FutureState< T >> state)
 
 Promise (Promise const &)=delete
 
Promiseoperator= (Promise const &)=delete
 
 Promise (Promise &&that)
 
Promiseoperator= (Promise &&that)
 
Future< T > get_future ()
 
void set_value (T value)
 
void set_exception (std::exception_ptr exception)
 
 ~Promise ()
 

Constructor & Destructor Documentation

◆ Promise() [1/8]

template<class T>
simgrid::kernel::Promise< T >::Promise ( )
inline

◆ Promise() [2/8]

template<class T>
simgrid::kernel::Promise< T >::Promise ( std::shared_ptr< FutureState< T >>  state)
inline

◆ Promise() [3/8]

template<class T>
simgrid::kernel::Promise< T >::Promise ( Promise< T > const &  )
delete

◆ Promise() [4/8]

template<class T>
simgrid::kernel::Promise< T >::Promise ( Promise< T > &&  that)
inline

◆ ~Promise() [1/2]

template<class T>
simgrid::kernel::Promise< T >::~Promise ( )
inline

◆ Promise() [5/8]

template<class T>
simgrid::kernel::Promise< T >::Promise ( )
inline

◆ Promise() [6/8]

template<class T>
simgrid::kernel::Promise< T >::Promise ( std::shared_ptr< FutureState< T >>  state)
inline

◆ Promise() [7/8]

template<class T>
simgrid::kernel::Promise< T >::Promise ( Promise< T > const &  )
delete

◆ Promise() [8/8]

template<class T>
simgrid::kernel::Promise< T >::Promise ( Promise< T > &&  that)
inline

◆ ~Promise() [2/2]

template<class T>
simgrid::kernel::Promise< T >::~Promise ( )
inline

Member Function Documentation

◆ operator=() [1/4]

template<class T>
Promise& simgrid::kernel::Promise< T >::operator= ( Promise< T > const &  )
delete

◆ operator=() [2/4]

template<class T>
Promise& simgrid::kernel::Promise< T >::operator= ( Promise< T > &&  that)
inline

◆ get_future() [1/2]

template<class T>
Future<T> simgrid::kernel::Promise< T >::get_future ( )
inline

◆ set_value() [1/2]

template<class T>
void simgrid::kernel::Promise< T >::set_value ( value)
inline

◆ set_exception() [1/2]

template<class T>
void simgrid::kernel::Promise< T >::set_exception ( std::exception_ptr  exception)
inline

◆ operator=() [3/4]

template<class T>
Promise& simgrid::kernel::Promise< T >::operator= ( Promise< T > const &  )
delete

◆ operator=() [4/4]

template<class T>
Promise& simgrid::kernel::Promise< T >::operator= ( Promise< T > &&  that)
inline

◆ get_future() [2/2]

template<class T>
Future<T> simgrid::kernel::Promise< T >::get_future ( )
inline

◆ set_value() [2/2]

template<class T>
void simgrid::kernel::Promise< T >::set_value ( value)
inline

◆ set_exception() [2/2]

template<class T>
void simgrid::kernel::Promise< T >::set_exception ( std::exception_ptr  exception)
inline

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