HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
callback_flags.hpp
1// Copyright Take Vos 2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "../utility/utility.hpp"
8#include "../macros.hpp"
9#include <utility>
10
11hi_export_module(hikogui.concurrency.callback_flags);
12
13hi_export namespace hi::inline v1 {
14
15enum class callback_flags {
18 synchronous = 0x00,
19
22 local = 0x01,
23
26 main = 0x02,
27
30 timer = 0x03,
31
34 once = 0x1'00,
35};
36
37[[nodiscard]] constexpr callback_flags operator|(callback_flags const &lhs, callback_flags const &rhs) noexcept
38{
39 hi_assert((std::to_underlying(lhs) & 0xff) == 0 or (std::to_underlying(rhs) & 0xff) == 0);
40 return static_cast<callback_flags>(std::to_underlying(lhs) | std::to_underlying(rhs));
41}
42
43[[nodiscard]] constexpr bool is_once(callback_flags const &rhs) noexcept
44{
45 return to_bool(std::to_underlying(rhs) & std::to_underlying(callback_flags::once));
46}
47
48[[nodiscard]] constexpr bool is_synchronous(callback_flags const& rhs) noexcept
49{
50 return to_bool((std::to_underlying(rhs) & 0xff) == std::to_underlying(callback_flags::synchronous));
51}
52
53[[nodiscard]] constexpr bool is_local(callback_flags const& rhs) noexcept
54{
55 return to_bool((std::to_underlying(rhs) & 0xff) == std::to_underlying(callback_flags::local));
56}
57
58[[nodiscard]] constexpr bool is_main(callback_flags const& rhs) noexcept
59{
60 return to_bool((std::to_underlying(rhs) & 0xff) == std::to_underlying(callback_flags::main));
61}
62
63[[nodiscard]] constexpr bool is_timer(callback_flags const& rhs) noexcept
64{
65 return to_bool((std::to_underlying(rhs) & 0xff) == std::to_underlying(callback_flags::timer));
66}
67
68}
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
callback_flags
Definition callback_flags.hpp:15
@ synchronous
Call the function synchronously.
@ timer
Call the function asynchronously from the timer thread's loop.
@ once
Call the function once, then automatically unsubscribe.
@ local
Call the function asynchronously from the current thread's loop.
@ main
Call the function asynchronously from the main thread's loop.