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

realm / realm-core / thomas.goyne_420

20 Jun 2024 08:37PM UTC coverage: 90.964% (-0.002%) from 90.966%
thomas.goyne_420

Pull #7796

Evergreen

tgoyne
Derive upload completion entirely from the state of the history

Rather than tracking a bunch of derived state in-memory, check for upload
completion by checking if there are any unuploaded changesets. This is both
multiprocess-compatible and is more precise than the old checks, which had some
false-negatives.
Pull Request #7796: RCORE-2160 Make upload completion reporting multiprocess-compatible

102120 of 180324 branches covered (56.63%)

112 of 117 new or added lines in 8 files covered. (95.73%)

46 existing lines in 16 files now uncovered.

214645 of 235966 relevant lines covered (90.96%)

5898967.27 hits per line

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

40.0
/src/realm/util/optional.hpp
1
/*************************************************************************
2
 *
3
 * Copyright 2016 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
#pragma once
20
#ifndef REALM_UTIL_OPTIONAL_HPP
21
#define REALM_UTIL_OPTIONAL_HPP
22

23
#include <optional>
24
#include <ostream>
25

26
namespace realm {
27
namespace util {
28

29
template <class T>
30
using Optional = std::optional<T>;
31
using None = std::nullopt_t;
32

33
template <class T, class... Args>
34
Optional<T> some(Args&&... args)
35
{
107,766,136✔
36
    return std::make_optional<T>(std::forward<Args>(args)...);
107,766,136✔
37
}
107,766,136✔
38

39
using std::make_optional;
40

41
constexpr auto none = std::nullopt;
42

43
template <class T>
44
struct RemoveOptional {
45
    using type = T;
46
};
47
template <class T>
48
struct RemoveOptional<Optional<T>> {
49
    using type = typename RemoveOptional<T>::type; // Remove recursively
50
};
51

52
/**
53
 * Writes a T to an ostream, with special handling if T is a std::optional.
54
 *
55
 * This function supports both optional and non-optional Ts, so that callers don't need to do their own dispatch.
56
 */
57
template <class T>
58
std::ostream& stream_possible_optional(std::ostream& os, const T& rhs)
59
{
1,037,966✔
60
    return os << rhs;
1,037,966✔
61
}
1,037,966✔
62
template <class T>
63
std::ostream& stream_possible_optional(std::ostream& os, const std::optional<T>& rhs)
UNCOV
64
{
×
UNCOV
65
    if (rhs) {
×
UNCOV
66
        os << "some(" << *rhs << ")";
×
UNCOV
67
    }
×
68
    else {
×
69
        os << "none";
×
70
    }
×
UNCOV
71
    return os;
×
UNCOV
72
}
×
73

74
} // namespace util
75

76
using util::none;
77

78
} // namespace realm
79

80
#endif // REALM_UTIL_OPTIONAL_HPP
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