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
 
struct  _Future_error_object< _Cat >
 
class  _Associated_state< _Ty >
 
struct  _State_deleter< _Ty, _Alloc >
 
struct  _Deleter_base< _Ty >
 
struct  _State_deleter< _Ty, _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...)>
 
struct  _Is_launch_type< _Fty >
 
struct  _Is_launch_type< _Launch_type >
 
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, launch::any = async | deferred, launch::sync = deferred }
 
enum  future_status { future_status::ready, future_status::timeout, future_status::deferred }
 

Functions

launch operator& (launch _Left, launch _Right)
 
launch operator| (launch _Left, launch _Right)
 
launch operator^ (launch _Left, launch _Right)
 
launch operator~ (launch _Left)
 
launchoperator&= (launch &_Left, launch _Right)
 
launchoperator|= (launch &_Left, launch _Right)
 
launchoperator^= (launch &_Left, launch _Right)
 
_CRTIMP2_PURE _NO_RETURN (__CLRCALL_PURE_OR_CDECL _Throw_future_error(const error_code &_Code))
 
_CRTIMP2_PURE _NO_RETURN (__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
 
_CRTIMP2_PURE const char *__CLRCALL_PURE_OR_CDECL _Future_error_map (int) _NOEXCEPT
 
template<class _Alloc , class _Ty >
void _Delete_state (_Alloc _Al, _Associated_state< _Ty > *_State, _State_deleter< _Ty, _Alloc > *)
 
template<class _Ty , class _Allocx >
_Associated_state< _Ty > * _Make_associated_state (_Allocx _Al)
 
template<class _Fty , class _Allocx , class _Ty >
_Associated_state< _Ty > * _Make_packaged_state (const _Fty &_Fn, const _Allocx &_Al)
 
template<class _Fty , class _Alloc , class _Ty >
_Associated_state< _Ty > * _Make_packaged_state (_Fty &&_Fn, 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< typename result_of< _Fty(_ArgTypes...)>::type > _Async (_Launch_type _Policy, _Fty &&_Fnarg, _ArgTypes &&..._Args)
 
template<class _Fty , class... _ArgTypes>
future< typename result_of< typename enable_if<!_Is_launch_type< typename decay< _Fty >::type >::value, _Fty >::type(_ArgTypes...)>::type > async (_Fty &&_Fnarg, _ArgTypes &&..._Args)
 
template<class _Policy_type , class _Fty , class... _ArgTypes>
future< typename result_of< typename enable_if< _Is_launch_type< _Policy_type >::value, _Fty >::type(_ArgTypes...)>::type > async (_Policy_type _Policy, _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 
any 
sync 
45  { // names for launch options passed to async
46  async = 0x1,
47  deferred = 0x2,
48  any = async | deferred, // retained
49  sync = deferred
50  };
future< typename result_of< typename enable_if<!_Is_launch_type< typename decay< _Fty >::type >::value, _Fty >::type(_ArgTypes...)>::type > async(_Fty &&_Fnarg, _ArgTypes &&..._Args)
Definition: future:1893

Function Documentation

template<class _Fty , class... _ArgTypes>
future<typename result_of<_Fty(_ArgTypes...)>::type> _Async ( _Launch_type  _Policy,
_Fty &&  _Fnarg,
_ArgTypes &&...  _Args 
)
inline
1876  { // return a future object whose associated asynchronous state
1877  // manages a function object
1878  typedef typename result_of<_Fty(_ArgTypes...)>::type _Ret;
1879  typedef typename _P_arg_type<_Ret>::type _Ptype;
1880  _Promise<_Ptype> _Pr(_Get_associated_state<_Ret>(_Policy,
1881  _STD bind(_STD forward<_Fty>(_Fnarg),
1882  _STD forward<_ArgTypes>(_Args)...)));
1883  return (future<_Ret>(_Pr._Get_state_for_future(), _Nil_obj));
1884  }
_Fret type
Definition: future:1706
Definition: xrefwrap:102
static _Nil _Nil_obj
Definition: xtr1common:29
Definition: future:1099
template<class _Alloc , class _Ty >
void _Delete_state ( _Alloc  _Al,
_Associated_state< _Ty > *  _State,
_State_deleter< _Ty, _Alloc > *  _Deleter 
)
inline
546  { // delete _State and _Deleter using allocator _Al
547  typedef typename _Alloc::template rebind<_Associated_state<_Ty> >
548  ::other _State_allocator;
549  _State_allocator _St_alloc(_Al);
550  _St_alloc.destroy(_State);
551  _St_alloc.deallocate(_State, 1);
552 
553  typedef typename _Alloc::template rebind<_State_deleter<_Ty, _Alloc> >
554  ::other _Deleter_allocator;
555  _Deleter_allocator _Del_alloc(_Al);
556  _Del_alloc.destroy(_Deleter);
557  _Del_alloc.deallocate(_Deleter, 1);
558  }
_CRTIMP2_PURE const char* __CLRCALL_PURE_OR_CDECL _Future_error_map ( int  )
template<class _Ret , class _Fty >
_Associated_state<typename _P_arg_type<_Ret>::type>* _Get_associated_state ( _Launch_type  _Psync,
_Fty &&  _Fnarg 
)
inline
1854  { // construct associated asynchronous state object for the launch type
1855  switch (_Psync)
1856  { // select launch type
1857  case launch::async:
1858  return (new _Task_async_state<_Ret, false>(
1859  _STD forward<_Fty >(_Fnarg)));
1860 
1861  case launch::deferred:
1862  return (new _Deferred_async_state<_Ret>(
1863  _STD forward<_Fty >(_Fnarg)));
1864  default:
1865  return (new _Task_async_state<_Ret, true>(
1866  _STD forward<_Fty >(_Fnarg)));
1867  }
1868  }
Definition: future:882
Definition: future:853
template<class _Ty , class _Allocx >
_Associated_state<_Ty>* _Make_associated_state ( _Allocx  _Al)
inline
790  { // construct an _Associated_state object with an allocator
791  typedef _Wrap_alloc<_Allocx> _Alloc;
792  typedef typename _Alloc::template rebind<_Associated_state<_Ty> >
793  ::other _State_allocator;
794  _State_allocator _St_alloc(_Al);
795 
796  typedef typename _Alloc::template rebind<_State_deleter<_Ty, _Alloc> >
797  ::other _Deleter_allocator;
798  _Deleter_allocator _Del_alloc(_Al);
799  _State_deleter<_Ty, _Alloc> *_Del = _Del_alloc.allocate(1);
800  _Del_alloc.construct(_Del, _St_alloc);
801 
802  _Associated_state<_Ty> *_Res = _St_alloc.allocate(1);
803  _St_alloc.construct(_Res, _Del);
804  return (_Res);
805  }
Definition: future:231
Definition: future:235
Definition: xmemory0:747
template<class _Fty , class _Allocx , class _Ty >
_Associated_state<_Ty>* _Make_packaged_state ( const _Fty &  _Fn,
const _Allocx &  _Al 
)
inline
812  { // construct a _Packaged_state object with an allocator
813  typedef _Wrap_alloc<_Allocx> _Alloc;
814  typedef typename _Alloc::template rebind<_Packaged_state<_Fty> >
815  ::other _State_allocator;
816  _State_allocator _St_alloc(_Al);
817 
818  typedef typename _Alloc::template rebind<_State_deleter<_Fty, _Alloc> >
819  ::other _Deleter_allocator;
820  _Deleter_allocator _Del_alloc(_Al);
821  _State_deleter<_Fty, _Alloc> *_Del = _Del_alloc.allocate(1);
822  _Del_alloc.construct(_Del, _St_alloc);
823 
824  _Packaged_state<_Fty> *_Res = _St_alloc.allocate(1);
825  _St_alloc.construct(_Res, _Fn, _Del);
826  return (_Res);
827  }
Definition: future:563
Definition: future:235
Definition: xmemory0:747
template<class _Fty , class _Alloc , class _Ty >
_Associated_state<_Ty>* _Make_packaged_state ( _Fty &&  _Fn,
const _Alloc &  _Al 
)
inline
834  { // construct a _Packaged_state object with an allocator from
835  // an rvalue function object
836  typedef typename _Alloc::template rebind<_Packaged_state<_Fty> >
837  ::other _State_allocator;
838  _State_allocator _St_alloc(_Al);
839 
840  typedef typename _Alloc::template rebind<_State_deleter<_Fty, _Alloc> >
841  ::other _Deleter_allocator;
842  _Deleter_allocator _Del_alloc(_Al);
843  _State_deleter<_Fty, _Alloc> *_Del = _Del_alloc.allocate(1);
844  _Del_alloc.construct(_Del, _St_alloc);
845 
846  _Packaged_state<_Fty> *_Res = _St_alloc.allocate(1);
847  _St_alloc.construct(_Res, _STD forward<_Fty>(_Fn), _Del);
848  return (_Res);
849  }
Definition: future:563
Definition: future:235
_CRTIMP2_PURE _NO_RETURN ( __CLRCALL_PURE_OR_CDECL   _Throw_future_errorconst error_code &_Code)
_CRTIMP2_PURE _NO_RETURN ( __CLRCALL_PURE_OR_CDECL   _Rethrow_future_exception_XSTD exception_ptr _Ptr)
template<class _Fty , class... _ArgTypes>
future<typename result_of< typename enable_if<!_Is_launch_type< typename decay<_Fty>::type>::value, _Fty>::type(_ArgTypes...)>::type> async ( _Fty &&  _Fnarg,
_ArgTypes &&...  _Args 
)
inline
1894  { // return a future object whose associated asynchronous state
1895  // manages a function object
1896  return (_Async(launch::any, _Decay_copy(_STD forward<_Fty>(_Fnarg)),
1897  _Decay_copy(_STD forward<_ArgTypes>(_Args))...));
1898  }
future< typename result_of< _Fty(_ArgTypes...)>::type > _Async(_Launch_type _Policy, _Fty &&_Fnarg, _ArgTypes &&..._Args)
Definition: future:1874
template<class _Policy_type , class _Fty , class... _ArgTypes>
future<typename result_of< typename enable_if<_Is_launch_type< _Policy_type>::value, _Fty>::type(_ArgTypes...)>::type> async ( _Policy_type  _Policy,
_Fty &&  _Fnarg,
_ArgTypes &&...  _Args 
)
inline
1909  { // return a future object whose associated asynchronous state
1910  // manages a function object
1911  return (_Async(_Policy, _Decay_copy(_STD forward<_Fty>(_Fnarg)),
1912  _Decay_copy(_STD forward<_ArgTypes>(_Args))...));
1913  }
future< typename result_of< _Fty(_ArgTypes...)>::type > _Async(_Launch_type _Policy, _Fty &&_Fnarg, _ArgTypes &&..._Args)
Definition: future:1874
const error_category & future_category ( )
inline
225  { // return error_category object for future
227  }
Definition: future:212
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:224
Definition: system_error:195
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:224
Definition: system_error:286
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  }
const _Ty & _Right
Definition: algorithm:4087
launch& operator&= ( launch _Left,
launch  _Right 
)
inline
76  { /* return _Left&=_Right */
77  _Left = _Left & _Right;
78  return (_Left);
79  }
const _Ty & _Right
Definition: algorithm:4087
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  }
const _Ty & _Right
Definition: algorithm:4087
launch& operator^= ( launch _Left,
launch  _Right 
)
inline
88  { /* return _Left^=_Right */
89  _Left = _Left ^ _Right;
90  return (_Left);
91  }
const _Ty & _Right
Definition: algorithm:4087
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  }
const _Ty & _Right
Definition: algorithm:4087
launch& operator|= ( launch _Left,
launch  _Right 
)
inline
82  { /* return _Left|=_Right */
83  _Left = _Left | _Right;
84  return (_Left);
85  }
const _Ty & _Right
Definition: algorithm:4087
launch operator~ ( launch  _Left)
inline
71  { /* return ~_Left */
72  return (static_cast<launch>(~static_cast<unsigned int>(_Left)));
73  }
template<class _Ty >
void swap ( promise< _Ty > &  _Left,
promise< _Ty > &  _Right 
)
inline
1698  { // exchange _Left and _Right
1699  _Left.swap(_Right);
1700  }
void swap(promise &_Other) _NOEXCEPT
Definition: future:1511
template<class _Ty >
void swap ( packaged_task< _Ty > &  _Left,
packaged_task< _Ty > &  _Right 
)
inline
1833  { // exchange _Left and _Right
1834  _Left.swap(_Right);
1835  }