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

llnl / dftracer-utils / 23730905027

30 Mar 2026 06:22AM UTC coverage: 51.451% (+0.4%) from 51.022%
23730905027

push

github

rayandrew
chore(docs)!: regenerate C++ API reference pages from Doxygen XML

- Add generate_api_index.py script for automated API doc generation
- Rename core_common.rst to core_infrastructure.rst
- Update all API reference pages with current class/function signatures
- Add doxygen group annotations to public headers

BREAKING CHANGE: API reference page structure reorganized

23019 of 57787 branches covered (39.83%)

Branch coverage included in aggregate %.

20057 of 25936 relevant lines covered (77.33%)

13268.82 hits per line

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

51.93
/src/dftracer/utils/core/tasks/task_result.cpp
1
#include <dftracer/utils/core/tasks/task_result.h>
2

3
#include <cassert>
4

5
namespace dftracer::utils {
6

7
void TaskResult::set_value(std::any value) {
1,351✔
8
    value_ = std::move(value);
1,351✔
9
    publish(State::value);
1,351✔
10
}
1,353✔
11

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

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

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

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

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

39
void TaskResult::publish(State s) {
1,385✔
40
    std::vector<std::coroutine_handle<>> to_resume;
1,385✔
41
    {
42
        std::lock_guard<std::mutex> lock(mutex_);
1,382!
43
        state_.store(static_cast<std::uint8_t>(s), std::memory_order_release);
1,384✔
44
        to_resume.swap(continuations_);
1,384✔
45
    }
1,384✔
46
    cv_.notify_all();
1,387✔
47
    // Resume coroutine continuations OUTSIDE the lock.
48
    for (auto h : to_resume) {
1,389!
49
        if (h && !h.done()) {
×
50
            h.resume();
×
51
        }
52
    }
53
}
1,389✔
54

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

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

71
std::any TaskResult::get() const {
618✔
72
    wait();
618!
73
    std::lock_guard<std::mutex> lock(mutex_);
618!
74
    auto s = static_cast<State>(state_.load(std::memory_order_acquire));
618✔
75
    if (s == State::exception) {
618✔
76
        std::rethrow_exception(exception_);
9!
77
    }
78
    if (s == State::cancelled) {
612✔
79
        throw std::runtime_error("Task was cancelled");
×
80
    }
81
    return value_;  // returns COPY
918!
82
}
618✔
83

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

97
std::exception_ptr TaskResult::get_exception() const { return exception_; }
10✔
98

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

104
bool TaskResult::has_exception() const {
1,397✔
105
    return static_cast<State>(state_.load(std::memory_order_acquire)) ==
1,397✔
106
           State::exception;
698✔
107
}
108

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

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

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

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

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

140
}  // namespace dftracer::utils
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