7#include "../utility/utility.hpp"
9#include "../macros.hpp"
17hi_export_module(hikogui.concurrency.callback);
19hi_export
namespace hi {
37 auto const _ = std::scoped_lock(_mutex);
38 hi_assert(_thread_ids.
empty());
42 template<
typename Func>
50 auto const _ = std::scoped_lock(_mutex);
52 hi_assert(
not std::ranges::contains(_thread_ids, thread_id));
54 auto const d =
defer([&] {
55 std::erase(_thread_ids, thread_id);
59 return _func(
args...);
73template<
typename T =
void()>
76template<
typename T =
void()>
101 [[
nodiscard]]
long use_count()
const noexcept
103 return _impl.use_count();
114 return _impl.expired();
122 std::weak_ptr<base_impl_type> _impl;
172 template<
typename Func>
177 void reset()
noexcept
179 return _impl.reset();
182 [[
nodiscard]]
long use_count()
const noexcept
184 return _impl.use_count();
189 return static_cast<bool>(_impl);
201 template<
typename...
Args>
210 return (*_impl)(std::forward<Args>(
args)...);
216 template<
typename FunctionType>
235 return {_impl.lock()};
Functions and types for accessing operating system threads.
thread_id current_thread_id() noexcept
Get the current thread id.
@ other
The gui_event does not have associated data.
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378
Definition callback.hpp:24
Definition callback.hpp:32
Definition callback.hpp:74
Definition callback.hpp:77
bool expired() const noexcept
Check if the callback object is expired.
Definition callback.hpp:112
A callback function.
Definition callback.hpp:153
Defer execution of a lambda to the end of the scope.
Definition defer.hpp:21