Realm C++ SDK Version v2.2.0

realm_core_scheduler.hpp

1
2//
3// Copyright 2024 Realm Inc.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
18
19#ifndef CPPREALM_REALM_CORE_SCHEDULER_HPP
20#define CPPREALM_REALM_CORE_SCHEDULER_HPP
21
22#include <cpprealm/scheduler.hpp>
23
24namespace realm {
25 namespace util {
26 class Scheduler;
27 }
28}
29namespace realm::internal {
30
34 struct realm_core_scheduler final : public scheduler {
39 void invoke(std::function<void()> &&fn) final;
40
45 [[nodiscard]] bool is_on_thread() const noexcept final;
46
52 bool is_same_as(const scheduler *other) const noexcept final;
53
62 [[nodiscard]] bool can_invoke() const noexcept final;
63 ~realm_core_scheduler() final = default;
64 realm_core_scheduler() = delete;
65 explicit realm_core_scheduler(std::shared_ptr<util::Scheduler> s) : s(std::move(s)) {}
66 operator std::shared_ptr<util::Scheduler>();
67 private:
68 std::shared_ptr<util::Scheduler> s;
69 };
70
71 std::shared_ptr<util::Scheduler> create_scheduler_shim(const std::shared_ptr<scheduler>& s);
72} // namespace realm::internal
73
74#endif//CPPREALM_REALM_CORE_SCHEDULER_HPP
Definition: realm_core_scheduler.hpp:34
bool is_same_as(const scheduler *other) const noexcept final
Definition: realm_core_scheduler.cpp:14
bool can_invoke() const noexcept final
Definition: realm_core_scheduler.cpp:21
bool is_on_thread() const noexcept final
Definition: realm_core_scheduler.cpp:10
void invoke(std::function< void()> &&fn) final
Definition: realm_core_scheduler.cpp:6
Definition: scheduler.hpp:27