run_scope.cpp

src/types/run_scope.cpp

@file run_scope.cpp @brief gh#158: per-thread publication of the running turn's cancel token.

Owners: @tvanfossen

RunCancelScope

entropic::RunCancelScope::RunCancelScope(std::atomic< bool > *token)

Publish token as this thread's run cancel token.

src/types/run_scope.cpp:57

Show on the map →

Called by none

Calls none

Source · 4 lines
RunCancelScope::RunCancelScope(std::atomic<bool>* token)
    : previous_(t_run_cancel) {
    t_run_cancel = token;
}
Activity · 1 steps
lines 59–59t_run_cancel = token;

Requirements

REQ-LOOP-006

RunSessionScope

entropic::RunSessionScope::RunSessionScope(std::string key)

Publish key as this thread's run session key.

src/types/run_scope.cpp:104

Show on the map →

Called by none

Calls none

Source · 4 lines
RunSessionScope::RunSessionScope(std::string key)
    : previous_(t_run_session) {
    t_run_session = std::move(key);
}
Activity · 1 steps
lines 106–106t_run_session = std::move(key);

Requirements

REQ-LOOP-009

RunStreamScope

entropic::RunStreamScope::RunStreamScope(RunStreamFn fn, void *user_data)

Publish (fn, user_data) as this thread's stream sink.

src/types/run_scope.cpp:150

Show on the map →

Called by none

Calls none

Source · 5 lines
RunStreamScope::RunStreamScope(RunStreamFn fn, void* user_data)
    : previous_fn_(t_run_stream_fn), previous_ud_(t_run_stream_ud) {
    t_run_stream_fn = fn;
    t_run_stream_ud = user_data;
}
Activity · 2 steps
lines 152–152t_run_stream_fn = fn;lines 153–153t_run_stream_ud = user_data;

Requirements

REQ-LOOP-008

cancel_current_run

bool entropic::cancel_current_run()

Cancel the run executing on this thread (gh#158).

src/types/run_scope.cpp:68

Show on the map →

Called by handle_pause, on_stream_chunk

Calls none

Source · 7 lines
bool cancel_current_run() {
    if (t_run_cancel == nullptr) {
        return false;
    }
    t_run_cancel->store(true, std::memory_order_release);
    return true;
}
Activity · 4 steps
lines 69–69◇ if (t_run_cancel == nullptr)lines 70–70return false;lines 72–72t_run_cancel->store(true, std::memory_order_release);lines 73–73return true;

Requirements

REQ-LOOP-006

current_run_cancel

const std::atomic< bool > * entropic::current_run_cancel()

The cancel token of the run executing on this thread, if any.

src/types/run_scope.cpp:37

Source · 1 line
const std::atomic<bool>* current_run_cancel() { return t_run_cancel; }
Activity · 1 steps
lines 37–37return t_run_cancel;

Requirements

REQ-LOOP-006

current_run_cancelled

bool entropic::current_run_cancelled()

Whether THIS thread's run has been cancelled.

src/types/run_scope.cpp:45

Show on the map →

Called by generation_cancelled, poll_stop, request_cancelled, run_interrupted

Calls none

Source · 4 lines
bool current_run_cancelled() {
    return t_run_cancel != nullptr
        && t_run_cancel->load(std::memory_order_acquire);
}
Activity · 1 steps
lines 46–47return t_run_cancel != nullptr && t_run_cancel->load(std::memory_order_acquire);

Requirements

REQ-LOOP-006

current_run_session

std::string entropic::current_run_session()

The session key of the run executing on this thread (gh#166).

src/types/run_scope.cpp:95

Source · 1 line
std::string current_run_session() { return t_run_session; }
Activity · 1 steps
lines 95–95return t_run_session;

Requirements

REQ-LOOP-009

emit_to_current_run_stream

bool entropic::emit_to_current_run_stream(const char *chunk, size_t len)

Deliver a chunk to the stream sink published on THIS thread.

src/types/run_scope.cpp:137

Source · 5 lines
bool emit_to_current_run_stream(const char* chunk, size_t len) {
    const bool installed = t_run_stream_fn != nullptr;
    if (installed) { t_run_stream_fn(chunk, len, t_run_stream_ud); }
    return installed;
}
Activity · 4 steps
lines 138–138const bool installed = t_run_stream_fn != nullptr;lines 139–139◇ if (installed)lines 139–139t_run_stream_fn(chunk, len, t_run_stream_ud);lines 140–140return installed;

Requirements

REQ-LOOP-008

~RunCancelScope

entropic::RunCancelScope::~RunCancelScope()

Restore the previously installed token.

src/types/run_scope.cpp:82

Show on the map →

Called by none

Calls none

The index is older than this file: the lines it records no longer hold this function. Refresh the index to bundle its body.

Requirements

REQ-LOOP-006

~RunSessionScope

entropic::RunSessionScope::~RunSessionScope()

Restore the previously published key.

src/types/run_scope.cpp:115

Show on the map →

Called by none

Calls none

The index is older than this file: the lines it records no longer hold this function. Refresh the index to bundle its body.

Requirements

REQ-LOOP-009

~RunStreamScope

entropic::RunStreamScope::~RunStreamScope()

Restore the previously published sink.

src/types/run_scope.cpp:161

Show on the map →

Called by none

Calls none

The index is older than this file: the lines it records no longer hold this function. Refresh the index to bundle its body.

Requirements

REQ-LOOP-008