Lely core libraries  2.2.5
future.hpp File Reference

This header file is part of the event library; it contains the C++ interface for the futures and promises. More...

#include <lely/ev/exec.hpp>
#include <lely/ev/future.h>
#include <lely/libc/type_traits.hpp>
#include <lely/util/invoker.hpp>
#include <lely/util/result.hpp>
#include <utility>
#include <vector>
Include dependency graph for future.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  lely::ev::future_not_ready
 The exception thrown when retrieving the result of a future which is not ready or does not contain a reference to a shared state. More...
 
class  lely::ev::Future< T, E >
 A future. More...
 
class  lely::ev::Promise< T, E >
 A promise. More...
 
struct  lely::ev::detail::is_future< class >
 
struct  lely::ev::detail::is_future< Future< T, E > >
 
class  lely::ev::detail::AsyncTask< class, class >
 
class  lely::ev::detail::AsyncTask< Invoker, typename ::std::enable_if<!is_future< compat::invoke_result_t< Invoker > >::value >::type >
 
class  lely::ev::detail::AsyncTask< Invoker, typename ::std::enable_if< is_future< compat::invoke_result_t< Invoker > >::value >::type >
 
class  lely::ev::Future< T, E >
 A future. More...
 

Typedefs

template<class F , class... Args>
using lely::ev::AsyncTask = detail::AsyncTask< util::invoker_t< F, Args... > >
 A helper alias template for the result of lely::ev::make_async_task<F, Args...>().
 

Functions

template<class F , class... Args>
AsyncTask< F, Args... > * lely::ev::make_async_task (ev_exec_t *exec, F &&f, Args &&... args)
 Creates a task containing a Callable and its arguments and a future that will eventually hold the result (or the exception, if thrown) of the invocation.
 
Future<::std::size_t, void > lely::ev::when_all (ev_exec_t *exec, ::std::size_t n, ev_future_t *const *futures)
 
template<class Allocator >
Future<::std::size_t, void > lely::ev::when_all (ev_exec_t *exec, const ::std::vector< ev_future_t *, Allocator > &futures)
 
template<class InputIt >
typename ::std::enable_if< !::std::is_convertible< InputIt, ev_future_t * >::value, Future<::std::size_t, void > >::type lely::ev::when_all (ev_exec_t *exec, InputIt first, InputIt last)
 
template<class... Futures>
typename ::std::enable_if< compat::conjunction<::std::is_convertible< Futures, ev_future_t * >... >::value, Future<::std::size_t, void > >::type lely::ev::when_all (ev_exec_t *exec, Futures &&... futures)
 
Future<::std::size_t, void > lely::ev::when_any (ev_exec_t *exec, ::std::size_t n, ev_future_t *const *futures)
 
template<class Allocator >
Future<::std::size_t, void > lely::ev::when_any (ev_exec_t *exec, const ::std::vector< ev_future_t *, Allocator > &futures)
 
template<class InputIt >
typename ::std::enable_if< !::std::is_convertible< InputIt, ev_future_t * >::value, Future<::std::size_t, void > >::type lely::ev::when_any (ev_exec_t *exec, InputIt first, InputIt last)
 
template<class... Futures>
typename ::std::enable_if< compat::conjunction<::std::is_convertible< Futures, ev_future_t * >... >::value, Future<::std::size_t, void > >::type lely::ev::when_any (ev_exec_t *exec, Futures &&... futures)
 
template<class E = ::std::error_code>
Future< void, E > lely::ev::make_empty_future ()
 Creates a shared state of type lely::util::Result<void, E> that is immediately ready, with a successful result, then returns a future associated with that shared state. More...
 
template<class T , class E = ::std::error_code, class V = typename ::std::decay<T>::type>
Future< V, E > lely::ev::make_ready_future (T &&value)
 Creates a shared state of type lely::util::Result<V, E> that is immediately ready, with a successul result constructed from std::forward<T>(value), then returns a future associated with that shared state. More...
 
template<class T , class E , class V = typename ::std::decay<E>::type>
Future< T, V > lely::ev::make_error_future (E &&error)
 Creates a shared state of type lely::util::Result<T, V> that is immediately ready, with a failure result constructed from std::forward<E>(error), then returns a future associated with that shared state. More...
 
template<class F , class... Args>
AsyncTask< F, Args... >::future_type lely::ev::async (ev_exec_t *exec, F &&f, Args &&... args)
 Creates a task containing a Callable and its arguments, submits it for execution to the specified executor and returns a future that will eventually hold the result (or the exception, if thrown) of the invocation.
 

Detailed Description

This header file is part of the event library; it contains the C++ interface for the futures and promises.

See also
lely/ev/future.h
Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file future.hpp.

Function Documentation

◆ when_all() [1/4]

Future<::std::size_t, void> lely::ev::when_all ( ev_exec_t exec,
::std::size_t  n,
ev_future_t *const *  futures 
)
inline
See also
ev_future_when_all_n()

Definition at line 573 of file future.hpp.

◆ when_all() [2/4]

template<class Allocator >
Future<::std::size_t, void> lely::ev::when_all ( ev_exec_t exec,
const ::std::vector< ev_future_t *, Allocator > &  futures 
)
inline
See also
ev_future_when_all_n()

Definition at line 582 of file future.hpp.

◆ when_all() [3/4]

template<class InputIt >
typename ::std::enable_if< !::std::is_convertible<InputIt, ev_future_t*>::value, Future<::std::size_t, void> >::type lely::ev::when_all ( ev_exec_t exec,
InputIt  first,
InputIt  last 
)
inline
See also
ev_future_when_all_n()

Definition at line 592 of file future.hpp.

◆ when_all() [4/4]

template<class... Futures>
typename ::std::enable_if< compat::conjunction<::std::is_convertible<Futures, ev_future_t*>...>::value, Future<::std::size_t, void> >::type lely::ev::when_all ( ev_exec_t exec,
Futures &&...  futures 
)
inline
See also
ev_future_when_all_n()

Definition at line 601 of file future.hpp.

◆ when_any() [1/4]

Future<::std::size_t, void> lely::ev::when_any ( ev_exec_t exec,
::std::size_t  n,
ev_future_t *const *  futures 
)
inline
See also
ev_future_when_any_n()

Definition at line 610 of file future.hpp.

◆ when_any() [2/4]

template<class Allocator >
Future<::std::size_t, void> lely::ev::when_any ( ev_exec_t exec,
const ::std::vector< ev_future_t *, Allocator > &  futures 
)
inline
See also
ev_future_when_any_n()

Definition at line 619 of file future.hpp.

◆ when_any() [3/4]

template<class InputIt >
typename ::std::enable_if< !::std::is_convertible<InputIt, ev_future_t*>::value, Future<::std::size_t, void> >::type lely::ev::when_any ( ev_exec_t exec,
InputIt  first,
InputIt  last 
)
inline
See also
ev_future_when_any_n()

Definition at line 629 of file future.hpp.

◆ when_any() [4/4]

template<class... Futures>
typename ::std::enable_if< compat::conjunction<::std::is_convertible<Futures, ev_future_t*>...>::value, Future<::std::size_t, void> >::type lely::ev::when_any ( ev_exec_t exec,
Futures &&...  futures 
)
inline
See also
ev_future_when_any_n()

Definition at line 638 of file future.hpp.

◆ make_empty_future()

template<class E = ::std::error_code>
Future<void, E> lely::ev::make_empty_future ( )
inline

Creates a shared state of type lely::util::Result<void, E> that is immediately ready, with a successful result, then returns a future associated with that shared state.

See also
make_ready_future(), make_error_future()

Definition at line 654 of file future.hpp.

◆ make_ready_future()

template<class T , class E = ::std::error_code, class V = typename ::std::decay<T>::type>
Future<V, E> lely::ev::make_ready_future ( T &&  value)
inline

Creates a shared state of type lely::util::Result<V, E> that is immediately ready, with a successul result constructed from std::forward<T>(value), then returns a future associated with that shared state.

See also
make_ready_future(), make_error_future()

Definition at line 671 of file future.hpp.

◆ make_error_future()

template<class T , class E , class V = typename ::std::decay<E>::type>
Future<T, V> lely::ev::make_error_future ( E &&  error)
inline

Creates a shared state of type lely::util::Result<T, V> that is immediately ready, with a failure result constructed from std::forward<E>(error), then returns a future associated with that shared state.

See also
make_ready_future(), make_error_future()

Definition at line 687 of file future.hpp.