Zth (libzth)
Loading...
Searching...
No Matches
async.h File Reference
#include <libzth/macros.h>
#include <libzth/allocator.h>
#include <libzth/config.h>
#include <libzth/exception.h>
#include <libzth/fiber.h>
#include <libzth/sync.h>
#include <libzth/util.h>
#include <libzth/worker.h>
#include <initializer_list>
#include <tuple>
#include <type_traits>

Go to the source code of this file.

Classes

class  zth::TypedFiber< R >
 Typed fiber class. More...
 
struct  zth::FiberManipulator
 
struct  zth::setStackSize
 Change the stack size of a fiber returned by zth_async. More...
 
struct  zth::setName
 Change the name of a fiber returned by zth_async. More...
 
struct  zth::passOnExit
 Makes the fiber pass the given gate upon exit. More...
 
struct  zth::asFuture
 Forces the fiber to have a future that outlives the fiber. More...
 
class  zth::TypedFiberN< F, R, Args >
 Actual fiber implementation for arbitrary function types and arguments. More...
 
class  zth::TypedFiberN< F, void, Args >
 
struct  zth::remove_function_cvref< F >
 
struct  zth::functor_operator_type< T >
 
struct  zth::functor_operator_type< R(Args...)>
 
struct  zth::functor_traits< F >
 
struct  zth::functor_traits< R(*)(Args...)>
 
struct  zth::functor_traits< R(*&)(Args...)>
 
struct  zth::functor_traits< R(&)(Args...)>
 
struct  zth::functor_traits< R(Args...)>
 
struct  zth::TypedFiberType< F >
 
struct  zth::TypedFiberType< F >::NoArg
 
struct  zth::function_type_helper< F >
 
struct  zth::function_type_helper< R(Args...)>
 
struct  zth::function_type_helper< R(*)(Args...)>
 
struct  zth::function_type_helper< R(*&)(Args...)>
 
struct  zth::function_type_helper< R(&)(Args...)>
 
class  zth::TypedFiberFactory< F >
 
struct  zth::fiber_type< F >
 
struct  zth::impl::is_function_< F >
 
struct  zth::impl::is_function_< T(Args...)>
 
struct  zth::is_function< T >
 
struct  zth::has_call_operator< T >
 
struct  zth::is_callable< T >
 
struct  zth::impl::fiber_future_helper< T, bool >
 
struct  zth::impl::fiber_future_helper< T, false >
 
struct  zth::fiber_future< T >
 The future returned by a fiber. More...
 
class  zth::joiner
 RAII class to join fibers and futures on destruction. More...
 

Namespaces

namespace  zth
 
namespace  zth::impl
 
namespace  zth::fibered
 

Macros

#define ZTH_TYPEDFIBER98   0
 
#define REMOVE_FUNCTION_CVREF_SPECIALIZATIONS_(P, PArgs, suffix, ...)
 
#define REMOVE_FUNCTION_CVREF_SPECIALIZATIONS_A(P, suffix)
 
#define REMOVE_FUNCTION_CVREF_SPECIALIZATIONS(P, suffix)
 
#define REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS_(PArgs, cvref, ...)
 
#define REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS_A(cvref)
 
#define REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS(cvref)
 
#define REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS_CV(...)
 
#define zth_fiber_declare_1(f)
 
#define zth_fiber_declare(...)
 Do the declaration part of zth_fiber() (to be used in an .h file).
 
#define zth_fiber_define_1(storage, f)
 
#define zth_fiber_define_extern_1(f)   zth_fiber_define_1(extern, f)
 
#define zth_fiber_define_static_1(f)   zth_fiber_define_1(static constexpr, f)
 
#define zth_fiber_define(...)
 Do the definition part of zth_fiber() (to be used in a .cpp file).
 
#define zth_fiber(...)
 Prepare every given function to become a fiber by zth_async.
 
#define zth_async
 Run a function as a new fiber.
 

Functions

template<typename R >
TypedFiber< R > & zth::operator<< (TypedFiber< R > &fiber, setStackSize const &m)
 
template<typename R >
TypedFiber< R > & zth::operator<< (TypedFiber< R > &fiber, setName const &m)
 
template<typename R >
TypedFiber< R > & zth::operator<< (TypedFiber< R > &fiber, setName &&m)
 
template<typename R >
TypedFiber< R > & zth::operator<< (TypedFiber< R > &fiber, passOnExit const &m)
 
template<typename R >
SharedReference< typename TypedFiber< R >::Future_type > zth::operator<< (TypedFiber< R > &fiber, asFuture const &)
 
template<typename F >
fiber_type< F >::factory zth::factory (F &&f, char const *name=nullptr)
 Create a new fiber.
 
template<typename F >
fiber_type< F >::factory zth::factory (F const &f, char const *name=nullptr)
 
template<typename F , typename... Args>
fiber_type< F >::fiber zth::fiber (F &&f, Args &&... args)
 Create and start a new fiber.
 
template<typename F >
 zth::fiber_future (F &) -> fiber_future< typename F::factory::Return >
 
template<typename F >
 zth::fiber_future (F const &) -> fiber_future< typename F::factory::Return >
 
int zth_fiber_create (void(*f)(void *), void *arg=nullptr, size_t stack=0, char const *name=nullptr) noexcept
 Run a function as a new fiber.
 

Macro Definition Documentation

◆ REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS

#define REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS (   cvref)
Value:
REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS_((Args...), cvref, typename... Args)
#define REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS_A(cvref)
Definition async.h:723

Definition at line 727 of file async.h.

◆ REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS_

#define REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS_ (   PArgs,
  cvref,
  ... 
)
Value:
template <typename R, typename C, ##__VA_ARGS__> \
struct remove_function_cvref<R(C::*) PArgs cvref> { \
typedef R(type) PArgs; \
};

Definition at line 701 of file async.h.

◆ REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS_A

#define REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS_A (   cvref)

Definition at line 723 of file async.h.

◆ REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS_CV

#define REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS_CV (   ...)
Value:
REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS(const __VA_ARGS__) \
REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS(volatile __VA_ARGS__) \
REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS(const volatile __VA_ARGS__)
#define REMOVE_FUNCTION_CVREF_MEMBER_SPECIALIZATIONS(cvref)
Definition async.h:727

Definition at line 735 of file async.h.

◆ REMOVE_FUNCTION_CVREF_SPECIALIZATIONS

#define REMOVE_FUNCTION_CVREF_SPECIALIZATIONS (   P,
  suffix 
)
Value:
REMOVE_FUNCTION_CVREF_SPECIALIZATIONS_(P, (Args...), suffix, typename... Args)
#define REMOVE_FUNCTION_CVREF_SPECIALIZATIONS_A(P, suffix)
Definition async.h:669

Definition at line 673 of file async.h.

◆ REMOVE_FUNCTION_CVREF_SPECIALIZATIONS_

#define REMOVE_FUNCTION_CVREF_SPECIALIZATIONS_ (   P,
  PArgs,
  suffix,
  ... 
)
Value:
template <typename R, ##__VA_ARGS__> \
struct remove_function_cvref<R P PArgs suffix> { \
typedef R(type) PArgs; \
};

Definition at line 646 of file async.h.

◆ REMOVE_FUNCTION_CVREF_SPECIALIZATIONS_A

#define REMOVE_FUNCTION_CVREF_SPECIALIZATIONS_A (   P,
  suffix 
)

Definition at line 669 of file async.h.

◆ zth_async

#define zth_async

Run a function as a new fiber.

The function must have passed through zth_fiber() (or friends) first. Example:

void foo(int i) { ... }
int main_fiber(int argc, char** argv) {
zth_async foo(42);
return 0;
}
#define zth_async
Run a function as a new fiber.
Definition async.h:1607
#define zth_fiber(...)
Prepare every given function to become a fiber by zth_async.
Definition async.h:1586
int main_fiber(int argc, char **argv)
Definition main.cpp:11

Definition at line 1607 of file async.h.

◆ zth_fiber

#define zth_fiber (   ...)

Prepare every given function to become a fiber by zth_async.

Definition at line 1586 of file async.h.

◆ zth_fiber_declare

#define zth_fiber_declare (   ...)

Do the declaration part of zth_fiber() (to be used in an .h file).

Definition at line 1560 of file async.h.

◆ zth_fiber_declare_1

#define zth_fiber_declare_1 (   f)
Value:
namespace zth { \
namespace fibered { \
extern ::zth::fiber_type<decltype(&::f)>::factory const f; \
} \
}
fiber_type< F >::factory factory(F &&f, char const *name=nullptr)
Create a new fiber.
Definition async.h:1131

Definition at line 1549 of file async.h.

◆ zth_fiber_define

#define zth_fiber_define (   ...)

Do the definition part of zth_fiber() (to be used in a .cpp file).

Definition at line 1580 of file async.h.

◆ zth_fiber_define_1

#define zth_fiber_define_1 (   storage,
 
)
Value:
namespace zth { \
namespace fibered { \
ZTH_DEPRECATED("Use zth::fiber(f, args...) instead") \
storage ::zth::fiber_type<decltype(&::f)>::factory const \
? ZTH_STRINGIFY(f) "()" \
: nullptr); /* NOLINT */ \
} \
} \
typedef ::zth::fiber_type<decltype(&::f)>::future f##_future;
static bool const EnablePerfEvent
Enable (but not necessarily record) perf.
Definition config.h:174
static bool const EnableDebugPrint
Actually do print the debug output.
Definition config.h:97
#define ZTH_STRINGIFY(x)
Converts the argument to a string literal.
Definition util.h:35

Definition at line 1562 of file async.h.

◆ zth_fiber_define_extern_1

#define zth_fiber_define_extern_1 (   f)    zth_fiber_define_1(extern, f)

Definition at line 1573 of file async.h.

◆ zth_fiber_define_static_1

#define zth_fiber_define_static_1 (   f)    zth_fiber_define_1(static constexpr, f)

Definition at line 1574 of file async.h.

◆ ZTH_TYPEDFIBER98

#define ZTH_TYPEDFIBER98   0

Definition at line 34 of file async.h.