execution 1.0.1
Portable task execution, timers, and process lifecycle
Loading...
Searching...
No Matches
main_executor.hpp
Go to the documentation of this file.
1/*
2 Copyright 2015 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5*/
6
7/**************************************************************************************************/
8
9#ifndef STLAB_CONCURRENCY_MAIN_EXECUTOR_HPP
10#define STLAB_CONCURRENCY_MAIN_EXECUTOR_HPP
11
46
47#include <stlab/execution/config.hpp>
48
49#if !STLAB_MAIN_EXECUTOR(NONE)
52
53#include <type_traits>
54#include <utility>
55#endif
56
57/**************************************************************************************************/
58
59#if !STLAB_MAIN_EXECUTOR(NONE)
60
61namespace stlab {
62inline namespace v2 {
63
67
80extern "C" void stlab_v2_main_executor_submit(const unsigned char* task_abi_guard,
81 const stlab_v2_task_concept* vtable,
82 stlab_v2_task_proc invoke,
83 void* source) noexcept;
84
92extern "C" [[noreturn]] void stlab_v2_main_executor_run();
93
95
96} // namespace v2
97} // namespace stlab
98
99#endif
100
101namespace stlab {
102STLAB_EXECUTION_VERSION_NAMESPACE_BEGIN()
103
104
109
110/**************************************************************************************************/
111
112namespace execution_detail {
113
114/**************************************************************************************************/
115
116#if !STLAB_MAIN_EXECUTOR(NONE)
117
119struct main_executor_type {
120 using result_type = void;
121
124 template <class F>
125 auto operator()(F&& f) const -> std::enable_if_t<std::is_nothrow_invocable_v<std::decay_t<F>>> {
126 task<void() noexcept> t{std::forward<F>(f)};
127 stlab_v2_main_executor_submit(&current_task_storage_abi_guard::value,
128 t.relocation_concept(), t.relocation_invoke(),
129 t.relocation_source());
130 }
131};
132
133/**************************************************************************************************/
134
135#endif
136
137} // namespace execution_detail
138
139#if !STLAB_MAIN_EXECUTOR(NONE)
140
144inline constexpr auto main_executor = execution_detail::main_executor_type{};
145
152[[noreturn]] inline void main_executor_run() { stlab_v2_main_executor_run(); }
153#endif
154
155/**************************************************************************************************/
156
158
159STLAB_EXECUTION_VERSION_NAMESPACE_END()
160} // namespace stlab
161
162/**************************************************************************************************/
163
164#endif // STLAB_CONCURRENCY_MAIN_EXECUTOR_HPP
Thread-pool executors mapping to the OS scheduler (libdispatch, Windows pool, portable).
void stlab_v2_main_executor_run()
Keeps the main queue serviced; never returns.
void stlab_v2_main_executor_submit(const unsigned char *task_abi_guard, const stlab_v2_task_concept *vtable, stlab_v2_task_proc invoke, void *source) noexcept
Submits one task to the main queue.
void(*)(void *) noexcept stlab_v2_task_proc
Function pointer type submitted through the shared executor ABI.
Definition default_executor.hpp:64
constexpr auto main_executor
Runs void() noexcept tasks on the configured main queue in submission order, except that cooperative ...
Definition main_executor.hpp:144
void main_executor_run()
Keeps the main queue serviced; never returns.
Definition main_executor.hpp:152
Definition default_executor.hpp:50
Definition default_executor.hpp:49
Versioned operation table used to relocate a task target across the shared executor ABI.
Definition task.hpp:64
Move-only callable wrapper for executor scheduling (task<Signature>).