49 constexpr awaiter_type()
noexcept =
default;
50 constexpr awaiter_type(awaiter_type&&)
noexcept =
default;
51 constexpr awaiter_type& operator=(awaiter_type
const&)
noexcept =
delete;
58 constexpr awaiter_type(awaiter_type
const& other) noexcept : _notifier(other._notifier) {}
65 constexpr awaiter_type&
operator=(awaiter_type&&other)
noexcept
69 _notifier = other._notifier;
74 [[nodiscard]]
constexpr bool await_ready() const noexcept
79 void await_suspend(std::coroutine_handle<> handle)
noexcept
81 hi_assert_not_null(_notifier);
85 _cbt = _notifier->subscribe(
86 [
this, handle](Args... args) {
89 _args = {std::forward<Args>(args)...};
94 callback_flags::main | callback_flags::once);
97 constexpr void await_resume() const noexcept
98 requires(sizeof...(Args) == 0)
102 constexpr auto await_resume() const noexcept
103 requires(sizeof...(Args) == 1)
105 return std::get<0>(_args);
108 constexpr auto await_resume() const noexcept
109 requires(sizeof...(Args) > 1)
115 notifier *_notifier =
nullptr;
116 callback<R(Args...)> _cbt;
150 auto callback = callback_type{std::forward<Func>(func)};
151 auto const lock = std::scoped_lock(_mutex);
152 _callbacks.emplace_back(callback, flags);
168 void operator()(Args... args) const noexcept
170 auto const lock = std::scoped_lock(_mutex);
172 for (
auto& [callback, flags] : _callbacks) {
173 if (is_synchronous(flags)) {
174 if (
auto cb = callback.lock()) {
175 cb(std::forward<Args>(args)...);
178 }
else if (is_local(flags)) {
179 loop_local_post_function([=] {
182 if (
auto cb = callback.lock()) {
189 }
else if (is_main(flags)) {
190 loop_main_post_function([=] {
193 if (
auto cb = callback.lock()) {
200 }
else if (is_timer(flags)) {
201 loop_timer_post_function([=] {
204 if (
auto cb = callback.lock()) {
219 if (is_once(flags)) {