Zth (libzth)
Loading...
Searching...
No Matches
future.h File Reference
#include <libzth/macros.h>
#include <libzth/sync.h>
#include <libzth/time.h>
#include <future>
#include <stdexcept>
#include <type_traits>

Go to the source code of this file.

Classes

struct  zth::type< T >
 
class  zth::impl::std_shared_future_base< T >
 
class  zth::impl::std_future_base< T >
 
class  zth::impl::std_promise_base< T >
 

Namespaces

namespace  zth
 
namespace  zth::impl
 
namespace  std
 STL namespace.
 

Macros

#define ZTH_FUTURE_CTORS(future_class_type)
 
#define ZTH_FUTURE_MOVE(future_class_type)
 
#define ZTH_FUTURE_COPY(future_class_type)
 

Typedefs

template<typename T >
using zth::promise = ::std::promise< zth::type< T > >
 
template<typename T >
using zth::future = ::std::future< zth::type< T > >
 
template<typename T >
using zth::shared_future = ::std::shared_future< zth::type< T > >
 
template<typename Func , typename... Args>
using zth::impl::invoke_result = typename std::invoke_result_t< Func, Args... >
 

Enumerations

enum class  zth::launch { zth::launch::detached = 1 , zth::launch::awaitable = 2 }
 Launch policies for std::async to start fibers instead of threads. More...
 

Functions

template<typename Func , typename... Args>
zth::future< zth::impl::invoke_result< Func, Args... > > zth::async (Func &&f, Args &&... args)
 
template<typename Func , typename... Args>
zth::future< zth::impl::invoke_result< Func, Args... > > zth::async (zth::launch policy, Func &&f, Args &&... args)
 
template<typename Func , typename... Args>
zth::future< zth::impl::invoke_result< Func, Args... > > std::async (zth::launch policy, Func &&f, Args &&... args)
 

Macro Definition Documentation

◆ ZTH_FUTURE_COPY

#define ZTH_FUTURE_COPY (   future_class_type)
Value:
future_class_type(future_class_type const& other) noexcept = default; \
\
future_class_type& operator=(future_class_type const& other) noexcept = default; \
\
future_class_type& operator=(zth::SharedPointer<Future_type> const& other) noexcept \
{ \
this->base::operator=(other); \
return *this; \
} \
\
future_class_type& operator=(zth::SharedReference<Future_type> const& other) noexcept \
{ \
this->base::operator=(other); \
return *this; \
}

Definition at line 140 of file future.h.

◆ ZTH_FUTURE_CTORS

#define ZTH_FUTURE_CTORS (   future_class_type)
Value:
using Future_type = typename base::Future_type; \
\
future_class_type() noexcept = default; \
\
future_class_type(zth::SharedPointer<Future_type> const& f) noexcept \
: base{f} \
{} \
\
future_class_type(zth::SharedReference<Future_type> const& f) noexcept \
: base{f} \
{}

Definition at line 72 of file future.h.

◆ ZTH_FUTURE_MOVE

#define ZTH_FUTURE_MOVE (   future_class_type)
Value:
future_class_type(future_class_type&& other) noexcept = default; \
\
future_class_type(zth::SharedPointer<Future_type>&& f) noexcept \
: base{std::move(f)} \
{} \
\
future_class_type(zth::SharedReference<Future_type>&& f) noexcept \
: base{std::move(f)} \
{} \
\
future_class_type& operator=(future_class_type&& other) noexcept = default; \
\
future_class_type& operator=(zth::SharedPointer<Future_type>&& other) noexcept \
{ \
this->base::operator=(std::move(other)); \
return *this; \
} \
\
future_class_type& operator=(zth::SharedReference<Future_type>&& other) noexcept \
{ \
this->base::operator=(std::move(other)); \
return *this; \
}

Definition at line 101 of file future.h.