STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Macros | Typedefs | Enumerations | Functions
future File Reference
#include <functional>
#include <system_error>
#include <utility>
#include <chrono>
#include <mutex>
#include <condition_variable>
#include <ppltasks.h>
#include <thread>

Classes

struct  is_error_code_enum< _Future_errc >
 
class  future_error
 
class  _Future_error_category
 
class  _Associated_state< _Ty >
 
struct  _Deleter_base< _Ty >
 
struct  _State_deleter< _Ty, _Derived, _Alloc >
 
class  _Associated_state< _Ty >
 
struct  _Associated_state< _Ty >::_Test_ready
 
struct  _Associated_state< _Ty >::_Anon
 
class  _Packaged_state< class >
 
class  _Packaged_state< _Ret(_ArgTypes...)>
 
class  _Packaged_state< _Ret &(_ArgTypes...)>
 
class  _Packaged_state< void(_ArgTypes...)>
 
class  _Deferred_async_state< _Rx >
 
class  _Task_async_state< _Rx, _Inline >
 
class  _State_manager< _Ty >
 
class  shared_future< _Ty >
 
class  future< _Ty >
 
class  future< _Ty & >
 
class  future< void >
 
class  shared_future< _Ty >
 
class  shared_future< _Ty & >
 
class  shared_future< void >
 
class  _Promise< _Ty >
 
class  promise< _Ty >
 
class  promise< _Ty & >
 
class  promise< void >
 
struct  _P_arg_type< _Fret >
 
struct  _P_arg_type< _Fret & >
 
struct  _P_arg_type< void >
 
class  packaged_task< class >
 
class  packaged_task< _Ret(_ArgTypes...)>
 
class  _Fake_no_copy_callable_adapter< _Types >
 
struct  std::uses_allocator< promise< _Ty >, _Alloc >
 
struct  std::uses_allocator< packaged_task< _Ty >, _Alloc >
 

Macros

#define _FUTURE_
 

Typedefs

typedef future_errc _Future_errc
 
typedef launch _Launch_type
 
typedef future_status _Future_status
 

Enumerations

enum  future_errc { future_errc::broken_promise = 1, future_errc::future_already_retrieved, future_errc::promise_already_satisfied, future_errc::no_state }
 
enum  launch { launch::async = 0x1, launch::deferred = 0x2 }
 
enum  future_status { future_status::ready, future_status::timeout, future_status::deferred }
 

Functions

constexpr launch operator& (launch _Left, launch _Right)
 
constexpr launch operator| (launch _Left, launch _Right)
 
constexpr launch operator^ (launch _Left, launch _Right)
 
constexpr launch operator~ (launch _Left)
 
launchoperator&= (launch &_Left, launch _Right)
 
launchoperator|= (launch &_Left, launch _Right)
 
launchoperator^= (launch &_Left, launch _Right)
 
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Throw_future_error (const error_code &_Code)
 
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Rethrow_future_exception (_XSTD exception_ptr _Ptr)
 
const error_categoryfuture_category () _NOEXCEPT
 
error_code make_error_code (_Future_errc _Errno) _NOEXCEPT
 
error_condition make_error_condition (_Future_errc _Errno) _NOEXCEPT
 
const char * _Future_error_map (int _Errcode) _NOEXCEPT
 
template<class _Ty , class _Alloc >
_Associated_state< _Ty > * _Make_associated_state (const _Alloc &_Al)
 
template<class _Pack_state , class _Fty2 , class _Alloc >
_Pack_state * _Make_packaged_state (_Fty2 &&_Fnarg, const _Alloc &_Al)
 
template<class _Ty >
void swap (promise< _Ty > &_Left, promise< _Ty > &_Right) _NOEXCEPT
 
template<class _Ty >
void swap (packaged_task< _Ty > &_Left, packaged_task< _Ty > &_Right) _NOEXCEPT
 
template<class _Ret , class _Fty >
_Associated_state< typename _P_arg_type< _Ret >::type > * _Get_associated_state (_Launch_type _Psync, _Fty &&_Fnarg)
 
template<class _Fty , class... _ArgTypes>
future< result_of_t< decay_t< _Fty >decay_t< _ArgTypes >...)> > async (launch _Policy, _Fty &&_Fnarg, _ArgTypes &&..._Args)
 
template<class _Fty , class... _ArgTypes>
future< result_of_t< decay_t< _Fty >decay_t< _ArgTypes >...)> > async (_Fty &&_Fnarg, _ArgTypes &&..._Args)
 

Macro Definition Documentation

#define _FUTURE_

Typedef Documentation

Enumeration Type Documentation

enum future_errc
strong
Enumerator
broken_promise 
future_already_retrieved 
promise_already_satisfied 
no_state 
enum future_status
strong
Enumerator
ready 
timeout 
deferred 
97  { // names for timed wait function returns
98  ready,
99  timeout,
100  deferred
101  };
enum launch
strong
Enumerator
async 
deferred 
47  { // names for launch options passed to async
48  async = 0x1,
49  deferred = 0x2
50  };
future< result_of_t< decay_t< _Fty >decay_t< _ArgTypes >...)> > async(launch _Policy, _Fty &&_Fnarg, _ArgTypes &&..._Args)
Definition: future:1919

Function Documentation

const char* _Future_error_map ( int  _Errcode)
inline
132  { // convert to name of future error
133  switch (static_cast<_Future_errc>(_Errcode))
134  { // switch on error code value
136  return ("broken promise");
137 
139  return ("future already retrieved");
140 
142  return ("promise already satisfied");
143 
145  return ("no state");
146 
147  default:
148  return (0);
149  }
150  }
template<class _Ret , class _Fty >
_Associated_state<typename _P_arg_type<_Ret>::type>* _Get_associated_state ( _Launch_type  _Psync,
_Fty &&  _Fnarg 
)
inline
1901  { // construct associated asynchronous state object for the launch type
1902  switch (_Psync)
1903  { // select launch type
1904  case launch::async:
1905  return (new _Task_async_state<_Ret, false>(
1906  _STD forward<_Fty>(_Fnarg)));
1907  case launch::deferred:
1908  return (new _Deferred_async_state<_Ret>(
1909  _STD forward<_Fty>(_Fnarg)));
1910  default:
1911  return (new _Task_async_state<_Ret, true>(
1912  _STD forward<_Fty>(_Fnarg)));
1913  }
1914  }
Definition: future:891
Definition: future:857
template<class _Ty , class _Alloc >
_Associated_state<_Ty>* _Make_associated_state ( const _Alloc &  _Al)
inline
769  { // construct an _Associated_state object with an allocator
770  typedef _State_deleter<_Ty, _Associated_state<_Ty>, _Alloc> _Delty;
771  typedef _Wrap_alloc<_Alloc> _Alty0;
772 
773  typedef typename _Alty0::template rebind<_Delty>
774  ::other _Deleter_allocator;
775  typedef typename _Alty0::template rebind<_Associated_state<_Ty> >
776  ::other _State_allocator;
777 
778  _Deleter_allocator _Del_alloc(_Al);
779  _State_allocator _St_alloc(_Al);
780 
781  _Delty *_Del = 0;
782  _Associated_state<_Ty> *_Res = 0;
783 
784  _Del = _Del_alloc.allocate(1);
785 
786  bool _Del_constructed = false;
787 
788  _TRY_BEGIN
789  _Del_alloc.construct(_Del, _Al);
790  _Del_constructed = true;
791 
792  _Res = _St_alloc.allocate(1);
793 
794  _St_alloc.construct(_Res, _Del);
795  _CATCH_ALL
796  if (_Res)
797  _St_alloc.deallocate(_Res, 1);
798 
799  if (_Del_constructed)
800  _Del_alloc.destroy(_Del);
801 
802  _Del_alloc.deallocate(_Del, 1);
803  _RERAISE;
804  _CATCH_END
805 
806  return (_Res);
807  }
Definition: future:217
#define _TRY_BEGIN
Definition: xstddef:60
#define _CATCH_END
Definition: xstddef:63
Definition: future:231
#define _CATCH_ALL
Definition: xstddef:62
Definition: xmemory0:380
#define _RERAISE
Definition: xstddef:74
template<class _Pack_state , class _Fty2 , class _Alloc >
_Pack_state* _Make_packaged_state ( _Fty2 &&  _Fnarg,
const _Alloc &  _Al 
)
inline
813  { // construct a _Packaged_state object with an allocator from
814  // an rvalue function object
815  typedef _State_deleter<typename _Pack_state::_Mybase::_State_type,
816  _Pack_state, _Alloc> _Delty;
817  typedef _Wrap_alloc<_Alloc> _Alty0;
818 
819  typedef typename _Alty0::template rebind<_Delty>
820  ::other _Deleter_allocator;
821  typedef typename _Alty0::template rebind<_Pack_state>
822  ::other _State_allocator;
823 
824  _Deleter_allocator _Del_alloc(_Al);
825  _State_allocator _St_alloc(_Al);
826 
827  _Delty *_Del = 0;
828  _Pack_state *_Res = 0;
829 
830  _Del = _Del_alloc.allocate(1);
831 
832  bool _Del_constructed = false;
833 
834  _TRY_BEGIN
835  _Del_alloc.construct(_Del, _Al);
836  _Del_constructed = true;
837 
838  _Res = _St_alloc.allocate(1);
839 
840  _St_alloc.construct(_Res, _STD forward<_Fty2>(_Fnarg), _Al, _Del);
841  _CATCH_ALL
842  if (_Res)
843  _St_alloc.deallocate(_Res, 1);
844 
845  if (_Del_constructed)
846  _Del_alloc.destroy(_Del);
847 
848  _Del_alloc.deallocate(_Del, 1);
849  _RERAISE;
850  _CATCH_END
851 
852  return (_Res);
853  }
#define _TRY_BEGIN
Definition: xstddef:60
#define _CATCH_END
Definition: xstddef:63
Definition: future:231
#define _CATCH_ALL
Definition: xstddef:62
Definition: xmemory0:380
#define _RERAISE
Definition: xstddef:74
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Rethrow_future_exception ( _XSTD exception_ptr  _Ptr)
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Throw_future_error ( const error_code _Code)
template<class _Fty , class... _ArgTypes>
future<result_of_t<decay_t<_Fty>decay_t<_ArgTypes>...)> > async ( launch  _Policy,
_Fty &&  _Fnarg,
_ArgTypes &&...  _Args 
)
inline
1920  { // return a future object whose associated asynchronous state
1921  // manages a callable object launched with supplied policy
1923  typedef typename _P_arg_type<_Ret>::type _Ptype;
1924  _Promise<_Ptype> _Pr(_Get_associated_state<_Ret>(_Policy,
1926  _STD forward<_Fty>(_Fnarg),
1927  _STD forward<_ArgTypes>(_Args)...
1928  )));
1929 
1930  return (future<_Ret>(_Pr._Get_state_for_future(), _Nil()));
1931  }
_Fret type
Definition: future:1730
typename decay< _Ty >::type decay_t
Definition: type_traits:1873
Definition: future:1865
Definition: future:1111
Definition: xtr1common:15
typename result_of< _Ty >::type result_of_t
Definition: type_traits:1891
template<class _Fty , class... _ArgTypes>
future<result_of_t<decay_t<_Fty>decay_t<_ArgTypes>...)> > async ( _Fty &&  _Fnarg,
_ArgTypes &&...  _Args 
)
inline
1937  { // return a future object whose associated asynchronous state
1938  // manages a callable object launched with default policy
1940  _STD forward<_Fty>(_Fnarg),
1941  _STD forward<_ArgTypes>(_Args)...
1942  ));
1943  }
future< result_of_t< decay_t< _Fty >decay_t< _ArgTypes >...)> > async(launch _Policy, _Fty &&_Fnarg, _ArgTypes &&..._Args)
Definition: future:1919
const error_category & future_category ( )
inline
211  { // return error_category object for future
212  return (_Immortalize<_Future_error_category>());
213  }
error_code make_error_code ( _Future_errc  _Errno)
inline
121  { // make an error_code object
122  return (error_code(static_cast<int>(_Errno), future_category()));
123  }
const error_category & future_category() _NOEXCEPT
Definition: future:210
Definition: system_error:221
error_condition make_error_condition ( _Future_errc  _Errno)
inline
126  { // make an error_condition object
127  return (error_condition(static_cast<int>(_Errno), future_category()));
128  }
const error_category & future_category() _NOEXCEPT
Definition: future:210
Definition: system_error:294
constexpr launch operator& ( launch  _Left,
launch  _Right 
)
inline
53  { /* return _Left&_Right */
54  return (static_cast<launch>(static_cast<unsigned int>(_Left)
55  & static_cast<unsigned int>(_Right)));
56  }
constexpr const _Ty &() _Left
Definition: algorithm:3590
constexpr const _Ty &() _Right
Definition: algorithm:3591
launch& operator&= ( launch _Left,
launch  _Right 
)
inline
76  { /* return _Left&=_Right */
77  _Left = _Left & _Right;
78  return (_Left);
79  }
constexpr const _Ty &() _Left
Definition: algorithm:3590
constexpr const _Ty &() _Right
Definition: algorithm:3591
constexpr launch operator^ ( launch  _Left,
launch  _Right 
)
inline
65  { /* return _Left^_Right */
66  return (static_cast<launch>(static_cast<unsigned int>(_Left)
67  ^ static_cast<unsigned int>(_Right)));
68  }
constexpr const _Ty &() _Left
Definition: algorithm:3590
constexpr const _Ty &() _Right
Definition: algorithm:3591
launch& operator^= ( launch _Left,
launch  _Right 
)
inline
88  { /* return _Left^=_Right */
89  _Left = _Left ^ _Right;
90  return (_Left);
91  }
constexpr const _Ty &() _Left
Definition: algorithm:3590
constexpr const _Ty &() _Right
Definition: algorithm:3591
constexpr launch operator| ( launch  _Left,
launch  _Right 
)
inline
59  { /* return _Left|_Right */
60  return (static_cast<launch>(static_cast<unsigned int>(_Left)
61  | static_cast<unsigned int>(_Right)));
62  }
constexpr const _Ty &() _Left
Definition: algorithm:3590
constexpr const _Ty &() _Right
Definition: algorithm:3591
launch& operator|= ( launch _Left,
launch  _Right 
)
inline
82  { /* return _Left|=_Right */
83  _Left = _Left | _Right;
84  return (_Left);
85  }
constexpr const _Ty &() _Left
Definition: algorithm:3590
constexpr const _Ty &() _Right
Definition: algorithm:3591
constexpr launch operator~ ( launch  _Left)
inline
71  { /* return ~_Left */
72  return (static_cast<launch>(~static_cast<unsigned int>(_Left)));
73  }
constexpr const _Ty &() _Left
Definition: algorithm:3590
template<class _Ty >
void swap ( promise< _Ty > &  _Left,
promise< _Ty > &  _Right 
)
inline
1722  { // exchange _Left and _Right
1723  _Left.swap(_Right);
1724  }
void swap(promise &_Other) _NOEXCEPT
Definition: future:1522
template<class _Ty >
void swap ( packaged_task< _Ty > &  _Left,
packaged_task< _Ty > &  _Right 
)
inline
1859  { // exchange _Left and _Right
1860  _Left.swap(_Right);
1861  }