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

llnl / dftracer-utils / 28982597416

08 Jul 2026 11:22PM UTC coverage: 50.709% (-1.9%) from 52.577%
28982597416

Pull #87

github

web-flow
Merge fdf73a826 into 4908d9921
Pull Request #87: fix(comparator): fix wrong counting files

16259 of 43579 branches covered (37.31%)

Branch coverage included in aggregate %.

37 of 38 new or added lines in 4 files covered. (97.37%)

616 existing lines in 111 files now uncovered.

21634 of 31148 relevant lines covered (69.46%)

13117.41 hits per line

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

50.59
/src/dftracer/utils/core/tasks/task_result.cpp
1
#include <dftracer/utils/core/common/error.h>
2
#include <dftracer/utils/core/tasks/task_result.h>
3

4
#include <cassert>
5

6
namespace dftracer::utils {
7

8
void TaskResult::set_value(std::any value) {
763✔
9
    value_ = std::move(value);
763✔
10
    publish(State::value);
765✔
11
}
758✔
12

13
void TaskResult::set_exception(std::exception_ptr ex) {
17✔
14
    exception_ = ex;
17✔
15
    publish(State::exception);
17✔
16
}
17✔
17

18
void TaskResult::set_cancelled() { publish(State::cancelled); }
×
19

20
void TaskResult::mark_running() {
784✔
21
    auto expected = static_cast<std::uint8_t>(State::pending);
784✔
22
    state_.compare_exchange_strong(
784✔
23
        expected, static_cast<std::uint8_t>(State::running),
24
        std::memory_order_release, std::memory_order_relaxed);
25
}
784✔
26

27
void TaskResult::add_reader() {
567✔
28
    pending_readers_.fetch_add(1, std::memory_order_relaxed);
567✔
29
}
567✔
30

31
void TaskResult::release_reader() {
533✔
32
    int prev = pending_readers_.fetch_sub(1, std::memory_order_acq_rel);
533✔
33
    if (prev == 1) {
533✔
34
        // Last reader released -- free value memory
35
        std::lock_guard<std::mutex> lock(mutex_);
332!
36
        value_ = std::any{};
331✔
37
    }
332✔
38
}
533✔
39

40
void TaskResult::publish(State s) {
781✔
41
    std::vector<std::coroutine_handle<>> to_resume;
781✔
42
    {
43
        std::lock_guard<std::mutex> lock(mutex_);
776!
44
        state_.store(static_cast<std::uint8_t>(s), std::memory_order_release);
774✔
45
        to_resume.swap(continuations_);
778✔
46
    }
778✔
47
    cv_.notify_all();
784✔
48
    // Resume coroutine continuations OUTSIDE the lock.
49
    for (auto h : to_resume) {
786!
UNCOV
50
        if (h && !h.done()) {
×
51
            h.resume();
×
52
        }
53
    }
54
}
779✔
55

56
bool TaskResult::wait(std::chrono::milliseconds timeout) const {
434✔
57
    auto ready = [this] {
434✔
58
        auto s = static_cast<State>(state_.load(std::memory_order_acquire));
434✔
59
        return s == State::value || s == State::exception ||
434!
60
               s == State::cancelled;
434✔
61
    };
434✔
62
    if (ready()) return true;
434!
63

64
    std::unique_lock<std::mutex> lock(mutex_);
×
65
    if (timeout.count() == 0) {
×
66
        cv_.wait(lock, ready);
×
67
        return true;
×
68
    }
69
    return cv_.wait_for(lock, timeout, ready);
×
UNCOV
70
}
×
71

72
std::any TaskResult::get() const {
345✔
73
    wait();
345!
74
    std::lock_guard<std::mutex> lock(mutex_);
345!
75
    auto s = static_cast<State>(state_.load(std::memory_order_acquire));
345✔
76
    if (s == State::exception) {
345✔
77
        std::rethrow_exception(exception_);
6✔
78
    }
79
    if (s == State::cancelled) {
342!
80
        throw DFTUtilsException(ErrorCode::PIPELINE, "Task was cancelled");
×
81
    }
82
    return value_;  // returns COPY
684!
83
}
345✔
84

85
std::any TaskResult::get_ready() const {
532✔
86
    std::lock_guard<std::mutex> lock(mutex_);
532!
87
    auto s = static_cast<State>(state_.load(std::memory_order_acquire));
533✔
88
    assert(s == State::value || s == State::exception || s == State::cancelled);
533!
89
    if (s == State::exception) {
533!
90
        std::rethrow_exception(exception_);
×
91
    }
92
    if (s == State::cancelled) {
533!
93
        throw DFTUtilsException(ErrorCode::PIPELINE, "Task was cancelled");
×
94
    }
95
    return value_;  // returns COPY
1,066!
96
}
532✔
97

98
std::exception_ptr TaskResult::get_exception() const { return exception_; }
5✔
99

100
bool TaskResult::is_ready() const {
7✔
101
    auto s = static_cast<State>(state_.load(std::memory_order_acquire));
7✔
102
    return s == State::value || s == State::exception || s == State::cancelled;
7!
103
}
104

105
bool TaskResult::has_exception() const {
792✔
106
    return static_cast<State>(state_.load(std::memory_order_acquire)) ==
792✔
107
           State::exception;
793✔
108
}
109

110
bool TaskResult::is_cancelled() const {
×
111
    return static_cast<State>(state_.load(std::memory_order_acquire)) ==
×
UNCOV
112
           State::cancelled;
×
113
}
114

115
TaskResult::State TaskResult::state() const {
×
116
    return static_cast<State>(state_.load(std::memory_order_acquire));
×
117
}
118

119
// WhenReadyAwaitable
120
bool TaskResult::WhenReadyAwaitable::await_ready() const noexcept {
×
121
    return result.is_ready();
×
122
}
123

124
bool TaskResult::WhenReadyAwaitable::await_suspend(std::coroutine_handle<> h) {
×
125
    std::lock_guard<std::mutex> lock(result.mutex_);
×
126
    // Double-check under lock -- result may have been published
127
    // between await_ready() and await_suspend().
128
    if (result.is_ready()) {
×
129
        return false;  // Don't suspend, resume immediately
×
130
    }
131
    result.continuations_.push_back(h);
×
132
    return true;       // Suspend
×
133
}
×
134

135
void TaskResult::WhenReadyAwaitable::await_resume() {
×
136
    if (result.has_exception()) {
×
137
        std::rethrow_exception(result.exception_);
×
138
    }
139
}
×
140

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

© 2026 Coveralls, Inc