• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

realm / realm-core / github_pull_request_312964

19 Feb 2025 07:31PM UTC coverage: 90.814% (-0.3%) from 91.119%
github_pull_request_312964

Pull #8071

Evergreen

web-flow
Bump serialize-javascript and mocha

Bumps [serialize-javascript](https://github.com/yahoo/serialize-javascript) to 6.0.2 and updates ancestor dependency [mocha](https://github.com/mochajs/mocha). These dependencies need to be updated together.


Updates `serialize-javascript` from 6.0.0 to 6.0.2
- [Release notes](https://github.com/yahoo/serialize-javascript/releases)
- [Commits](https://github.com/yahoo/serialize-javascript/compare/v6.0.0...v6.0.2)

Updates `mocha` from 10.2.0 to 10.8.2
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mochajs/mocha/compare/v10.2.0...v10.8.2)

---
updated-dependencies:
- dependency-name: serialize-javascript
  dependency-type: indirect
- dependency-name: mocha
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #8071: Bump serialize-javascript and mocha

96552 of 179126 branches covered (53.9%)

212672 of 234185 relevant lines covered (90.81%)

3115802.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.0
/src/realm/object-store/util/scheduler.cpp
1
////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2020 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
//
17
////////////////////////////////////////////////////////////////////////////
18

19
#include <realm/object-store/util/scheduler.hpp>
20
#include <realm/util/terminate.hpp>
21
#include <realm/version_id.hpp>
22

23
#if REALM_HAVE_UV
24
#include <realm/object-store/util/uv/scheduler.hpp>
25
#endif
26

27
#if REALM_PLATFORM_APPLE
28
#include <realm/object-store/util/apple/scheduler.hpp>
29
#endif
30

31
// When building Realm within the VNDK in AOSP, __ANDROID__ is defined.
32
// However, access to libandroid is restricted by VNDK policies.
33
// As a result, we cannot utilize the built-in ALooper functionality.
34
// Instead, we require users to provide their own scheduler implementation.
35

36
#if REALM_ANDROID && !defined(REALM_AOSP_VENDOR)
37
#define HAS_ANDROID_ALOOPER
38
#endif
39

40
#if defined(HAS_ANDROID_ALOOPER)
41
#include <realm/object-store/util/android/scheduler.hpp>
42
#endif
43

44
#if defined(__EMSCRIPTEN__)
45
#include <realm/object-store/util/emscripten/scheduler.hpp>
46
#endif
47

48
#include <realm/object-store/util/generic/scheduler.hpp>
49

50
namespace realm::util {
51
namespace {
52

53
std::shared_ptr<Scheduler> (*s_factory)() = Scheduler::make_platform_default;
54

55
class FrozenScheduler : public util::Scheduler {
56
public:
57
    FrozenScheduler(VersionID version)
58
        : m_version(version)
858✔
59
    {
858✔
60
    }
858✔
61

62
    void invoke(UniqueFunction<void()>&&) override {}
6,888✔
63
    bool is_on_thread() const noexcept override
64
    {
8,929✔
65
        return true;
8,929✔
66
    }
8,929✔
67
    bool is_same_as(const Scheduler* other) const noexcept override
68
    {
3✔
69
        auto o = dynamic_cast<const FrozenScheduler*>(other);
3✔
70
        return (o && (o->m_version == m_version));
3✔
71
    }
3✔
72
    bool can_invoke() const noexcept override
73
    {
×
74
        return false;
×
75
    }
×
76

77
private:
78
    VersionID m_version;
79
};
80

81
class DummyScheduler : public realm::util::Scheduler {
82
public:
83
    bool is_on_thread() const noexcept override
84
    {
5,356✔
85
        return true;
5,356✔
86
    }
5,356✔
87
    bool is_same_as(const Scheduler* other) const noexcept override
88
    {
×
89
        auto o = dynamic_cast<const DummyScheduler*>(other);
×
90
        return (o != nullptr);
×
91
    }
×
92
    bool can_invoke() const noexcept override
93
    {
×
94
        return false;
×
95
    }
×
96
    void invoke(UniqueFunction<void()>&&) override {}
63✔
97
};
98
} // anonymous namespace
99

100
void InvocationQueue::push(util::UniqueFunction<void()>&& fn)
101
{
31,518✔
102
    std::lock_guard lock(m_mutex);
31,518✔
103
    m_functions.push_back(std::move(fn));
31,518✔
104
}
31,518✔
105

106
void InvocationQueue::invoke_all()
107
{
1,566✔
108
    std::vector<util::UniqueFunction<void()>> functions;
1,566✔
109
    {
1,566✔
110
        std::lock_guard lock(m_mutex);
1,566✔
111
        functions.swap(m_functions);
1,566✔
112
    }
1,566✔
113
    for (auto&& fn : functions) {
3,574✔
114
        fn();
3,574✔
115
    }
3,574✔
116
}
1,566✔
117

118
Scheduler::~Scheduler() = default;
17,186✔
119

120
void Scheduler::set_default_factory(std::shared_ptr<Scheduler> (*factory)())
121
{
2✔
122
    s_factory = std::move(factory);
2✔
123
}
2✔
124

125
std::shared_ptr<Scheduler> Scheduler::make_default()
126
{
12,293✔
127
    return s_factory();
12,293✔
128
}
12,293✔
129

130
std::shared_ptr<Scheduler> Scheduler::make_platform_default()
131
{
×
132
#if REALM_USE_UV
133
    return make_uv();
134
#else
135
#if REALM_PLATFORM_APPLE
136
    return make_runloop(nullptr);
137
#elif defined(HAS_ANDROID_ALOOPER)
138
    return make_alooper();
139
#elif defined(__EMSCRIPTEN__)
140
    return std::make_shared<EmscriptenScheduler>();
141
#else
142
    REALM_TERMINATE("No built-in scheduler implementation for this platform. Register your own with "
143
                    "Scheduler::set_default_factory()");
×
144
#endif
×
145
#endif // REALM_USE_UV
×
146
}
×
147

148
std::shared_ptr<Scheduler> Scheduler::make_generic()
149
{
×
150
    return std::make_shared<GenericScheduler>();
×
151
}
×
152

153
std::shared_ptr<Scheduler> Scheduler::make_frozen(VersionID version)
154
{
858✔
155
    return std::make_shared<FrozenScheduler>(version);
858✔
156
}
858✔
157

158
std::shared_ptr<Scheduler> Scheduler::make_dummy()
159
{
4,029✔
160
    return std::make_shared<DummyScheduler>();
4,029✔
161
}
4,029✔
162

163
#if REALM_PLATFORM_APPLE
164
std::shared_ptr<Scheduler> Scheduler::make_runloop(CFRunLoopRef run_loop)
165
{
166
    if (!run_loop)
167
        run_loop = CFRunLoopGetCurrent();
168
    if (run_loop == CFRunLoopGetMain())
169
        return std::make_shared<MainRunLoopScheduler>();
170
    return std::make_shared<RunLoopScheduler>(run_loop);
171
}
172

173
std::shared_ptr<Scheduler> Scheduler::make_dispatch(void* queue)
174
{
175
    return std::make_shared<DispatchQueueScheduler>(static_cast<dispatch_queue_t>(queue));
176
}
177
#endif // REALM_PLATFORM_APPLE
178

179
#if defined(HAS_ANDROID_ALOOPER)
180
std::shared_ptr<Scheduler> Scheduler::make_alooper()
181
{
182
    return std::make_shared<ALooperScheduler>();
183
}
184
#endif // HAS_ANDROID_ALOOPER
185

186
#if REALM_HAVE_UV
187
std::shared_ptr<Scheduler> Scheduler::make_uv()
188
{
189
    return std::make_shared<UvMainLoopScheduler>();
190
}
191
#endif // REALM_HAVE_UV
192

193
} // namespace realm::util
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc