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
 
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 (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 
96  { // names for timed wait function returns
97  ready,
98  timeout,
99  deferred
100  };
enum launch
strong
Enumerator
async 
deferred 
46  { // names for launch options passed to async
47  async = 0x1,
48  deferred = 0x2
49  };
future< result_of_t< decay_t< _Fty >decay_t< _ArgTypes >...)> > async(launch _Policy, _Fty &&_Fnarg, _ArgTypes &&..._Args)
Definition: future:1915

Function Documentation

const char* _Future_error_map ( int  _Errcode)
inline
131  { // convert to name of future error
132  switch (static_cast<_Future_errc>(_Errcode))
133  { // switch on error code value
135  return ("broken promise");
136 
138  return ("future already retrieved");
139 
141  return ("promise already satisfied");
142 
144  return ("no state");
145 
146  default:
147  return (0);
148  }
149  }
template<class _Ret , class _Fty >
_Associated_state<typename _P_arg_type<_Ret>::type>* _Get_associated_state ( _Launch_type  _Psync,
_Fty &&  _Fnarg 
)
inline
1897  { // construct associated asynchronous state object for the launch type
1898  switch (_Psync)
1899  { // select launch type
1900  case launch::async:
1901  return (new _Task_async_state<_Ret, false>(
1902  _STD forward<_Fty>(_Fnarg)));
1903  case launch::deferred:
1904  return (new _Deferred_async_state<_Ret>(
1905  _STD forward<_Fty>(_Fnarg)));
1906  default:
1907  return (new _Task_async_state<_Ret, true>(
1908  _STD forward<_Fty>(_Fnarg)));
1909  }
1910  }
Definition: future:877
Definition: future:843
template<class _Ty , class _Alloc >
_Associated_state<_Ty>* _Make_associated_state ( const _Alloc &  _Al)
inline
755  { // construct an _Associated_state object with an allocator
756  typedef _State_deleter<_Ty, _Associated_state<_Ty>, _Alloc> _Delty;
757  typedef _Wrap_alloc<_Alloc> _Alty0;
758 
759  typedef typename _Alty0::template rebind<_Delty>
760  ::other _Deleter_allocator;
761  typedef typename _Alty0::template rebind<_Associated_state<_Ty> >
762  ::other _State_allocator;
763 
764  _Deleter_allocator _Del_alloc(_Al);
765  _State_allocator _St_alloc(_Al);
766 
767  typename _Deleter_allocator::pointer _Del{};
768  typename _State_allocator::pointer _Res{};
769 
770  _Del = _Del_alloc.allocate(1);
771 
772  bool _Del_constructed = false;
773 
774  _TRY_BEGIN
775  _Del_alloc.construct(_Unfancy(_Del), _Al);
776  _Del_constructed = true;
777 
778  _Res = _St_alloc.allocate(1);
779 
780  _St_alloc.construct(_Unfancy(_Res), _Unfancy(_Del));
781  _CATCH_ALL
782  if (_Res)
783  _St_alloc.deallocate(_Res, 1);
784 
785  if (_Del_constructed)
786  _Del_alloc.destroy(_Unfancy(_Del));
787 
788  _Del_alloc.deallocate(_Del, 1);
789  _RERAISE;
790  _CATCH_END
791 
792  return (_Unfancy(_Res));
793  }
#define _TRY_BEGIN
Definition: xstddef:26
#define _CATCH_END
Definition: xstddef:29
Definition: future:230
#define _CATCH_ALL
Definition: xstddef:28
Definition: xmemory0:483
auto _Unfancy(_Ptrty _Ptr)
Definition: xstddef:635
#define _RERAISE
Definition: xstddef:32
template<class _Pack_state , class _Fty2 , class _Alloc >
_Pack_state* _Make_packaged_state ( _Fty2 &&  _Fnarg,
const _Alloc &  _Al 
)
inline
799  { // construct a _Packaged_state object with an allocator from
800  // an rvalue function object
801  typedef _State_deleter<typename _Pack_state::_Mybase::_State_type,
802  _Pack_state, _Alloc> _Delty;
803  typedef _Wrap_alloc<_Alloc> _Alty0;
804 
805  typedef typename _Alty0::template rebind<_Delty>
806  ::other _Deleter_allocator;
807  typedef typename _Alty0::template rebind<_Pack_state>
808  ::other _State_allocator;
809 
810  _Deleter_allocator _Del_alloc(_Al);
811  _State_allocator _St_alloc(_Al);
812 
813  typename _Deleter_allocator::pointer _Del{};
814  typename _State_allocator::pointer _Res{};
815 
816  _Del = _Del_alloc.allocate(1);
817 
818  bool _Del_constructed = false;
819 
820  _TRY_BEGIN
821  _Del_alloc.construct(_Unfancy(_Del), _Al);
822  _Del_constructed = true;
823 
824  _Res = _St_alloc.allocate(1);
825 
826  _St_alloc.construct(_Unfancy(_Res), _STD forward<_Fty2>(_Fnarg), _Al, _Unfancy(_Del));
827  _CATCH_ALL
828  if (_Res)
829  _St_alloc.deallocate(_Res, 1);
830 
831  if (_Del_constructed)
832  _Del_alloc.destroy(_Unfancy(_Del));
833 
834  _Del_alloc.deallocate(_Del, 1);
835  _RERAISE;
836  _CATCH_END
837 
838  return (_Unfancy(_Res));
839  }
#define _TRY_BEGIN
Definition: xstddef:26
#define _CATCH_END
Definition: xstddef:29
Definition: future:230
#define _CATCH_ALL
Definition: xstddef:28
Definition: xmemory0:483
auto _Unfancy(_Ptrty _Ptr)
Definition: xstddef:635
#define _RERAISE
Definition: xstddef:32
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Rethrow_future_exception ( 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
1916  { // return a future object whose associated asynchronous state
1917  // manages a callable object launched with supplied policy
1919  typedef typename _P_arg_type<_Ret>::type _Ptype;
1920  _Promise<_Ptype> _Pr(_Get_associated_state<_Ret>(_Policy,
1922  _STD forward<_Fty>(_Fnarg),
1923  _STD forward<_ArgTypes>(_Args)...
1924  )));
1925 
1926  return (future<_Ret>(_Pr._Get_state_for_future(), _Nil()));
1927  }
_Fret type
Definition: future:1726
typename decay< _Ty >::type decay_t
Definition: type_traits:2095
Definition: future:1861
Definition: future:1102
Definition: xtr1common:16
typename result_of< _Ty >::type result_of_t
Definition: type_traits:2113
template<class _Fty , class... _ArgTypes>
future<result_of_t<decay_t<_Fty>decay_t<_ArgTypes>...)> > async ( _Fty &&  _Fnarg,
_ArgTypes &&...  _Args 
)
inline
1933  { // return a future object whose associated asynchronous state
1934  // manages a callable object launched with default policy
1936  _STD forward<_Fty>(_Fnarg),
1937  _STD forward<_ArgTypes>(_Args)...
1938  ));
1939  }
future< result_of_t< decay_t< _Fty >decay_t< _ArgTypes >...)> > async(launch _Policy, _Fty &&_Fnarg, _ArgTypes &&..._Args)
Definition: future:1915
const error_category & future_category ( )
inline
210  { // return error_category object for future
211  return (_Immortalize<_Future_error_category>());
212  }
error_code make_error_code ( _Future_errc  _Errno)
inline
120  { // make an error_code object
121  return (error_code(static_cast<int>(_Errno), future_category()));
122  }
const error_category & future_category() _NOEXCEPT
Definition: future:209
Definition: system_error:218
error_condition make_error_condition ( _Future_errc  _Errno)
inline
125  { // make an error_condition object
126  return (error_condition(static_cast<int>(_Errno), future_category()));
127  }
const error_category & future_category() _NOEXCEPT
Definition: future:209
Definition: system_error:291
constexpr launch operator& ( launch  _Left,
launch  _Right 
)
inline
52  { /* return _Left&_Right */
53  return (static_cast<launch>(static_cast<unsigned int>(_Left)
54  & static_cast<unsigned int>(_Right)));
55  }
constexpr const _Ty &() _Left
Definition: algorithm:3722
constexpr const _Ty &() _Right
Definition: algorithm:3723
launch& operator&= ( launch _Left,
launch  _Right 
)
inline
75  { /* return _Left&=_Right */
76  _Left = _Left & _Right;
77  return (_Left);
78  }
constexpr const _Ty &() _Left
Definition: algorithm:3722
constexpr const _Ty &() _Right
Definition: algorithm:3723
constexpr launch operator^ ( launch  _Left,
launch  _Right 
)
inline
64  { /* return _Left^_Right */
65  return (static_cast<launch>(static_cast<unsigned int>(_Left)
66  ^ static_cast<unsigned int>(_Right)));
67  }
constexpr const _Ty &() _Left
Definition: algorithm:3722
constexpr const _Ty &() _Right
Definition: algorithm:3723
launch& operator^= ( launch _Left,
launch  _Right 
)
inline
87  { /* return _Left^=_Right */
88  _Left = _Left ^ _Right;
89  return (_Left);
90  }
constexpr const _Ty &() _Left
Definition: algorithm:3722
constexpr const _Ty &() _Right
Definition: algorithm:3723
constexpr launch operator| ( launch  _Left,
launch  _Right 
)
inline
58  { /* return _Left|_Right */
59  return (static_cast<launch>(static_cast<unsigned int>(_Left)
60  | static_cast<unsigned int>(_Right)));
61  }
constexpr const _Ty &() _Left
Definition: algorithm:3722
constexpr const _Ty &() _Right
Definition: algorithm:3723
launch& operator|= ( launch _Left,
launch  _Right 
)
inline
81  { /* return _Left|=_Right */
82  _Left = _Left | _Right;
83  return (_Left);
84  }
constexpr const _Ty &() _Left
Definition: algorithm:3722
constexpr const _Ty &() _Right
Definition: algorithm:3723
constexpr launch operator~ ( launch  _Left)
inline
70  { /* return ~_Left */
71  return (static_cast<launch>(~static_cast<unsigned int>(_Left)));
72  }
constexpr const _Ty &() _Left
Definition: algorithm:3722
template<class _Ty >
void swap ( promise< _Ty > &  _Left,
promise< _Ty > &  _Right 
)
inline
1718  { // exchange _Left and _Right
1719  _Left.swap(_Right);
1720  }
void swap(promise &_Other) _NOEXCEPT
Definition: future:1518
template<class _Ty >
void swap ( packaged_task< _Ty > &  _Left,
packaged_task< _Ty > &  _Right 
)
inline
1855  { // exchange _Left and _Right
1856  _Left.swap(_Right);
1857  }