Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
run_scope.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
36#pragma once
37
39
40#include <atomic>
41#include <cstddef>
42#include <string>
43
44namespace entropic {
45
54ENTROPIC_EXPORT const std::atomic<bool>* current_run_cancel();
55
67ENTROPIC_EXPORT bool current_run_cancelled();
68
84ENTROPIC_EXPORT bool cancel_current_run();
85
98class ENTROPIC_EXPORT RunCancelScope {
99public:
111 explicit RunCancelScope(std::atomic<bool>* token);
112
120
121 RunCancelScope(const RunCancelScope&) = delete;
122 RunCancelScope& operator=(const RunCancelScope&) = delete;
123
124private:
125 std::atomic<bool>* previous_;
126};
127
145ENTROPIC_EXPORT std::string current_run_session();
146
158class ENTROPIC_EXPORT RunSessionScope {
159public:
167 explicit RunSessionScope(std::string key);
168
176
177 RunSessionScope(const RunSessionScope&) = delete;
178 RunSessionScope& operator=(const RunSessionScope&) = delete;
179
180private:
181 std::string previous_;
182};
183
185using RunStreamFn = void (*)(const char* chunk, size_t len, void* user_data);
186
202ENTROPIC_EXPORT bool emit_to_current_run_stream(const char* chunk, size_t len);
203
217class ENTROPIC_EXPORT RunStreamScope {
218public:
227 RunStreamScope(RunStreamFn fn, void* user_data);
228
236
237 RunStreamScope(const RunStreamScope&) = delete;
238 RunStreamScope& operator=(const RunStreamScope&) = delete;
239
240private:
241 RunStreamFn previous_fn_;
242 void* previous_ud_;
243};
244
245} // namespace entropic
RAII publication of one run's cancel token to its own thread.
Definition run_scope.h:98
RAII publication of one run's session key to its own thread.
Definition run_scope.h:158
RAII: publish a streaming run's sink to its own thread (gh#208).
Definition run_scope.h:217
Symbol visibility macro for all exported symbols.
Activate model on GPU (WARM → ACTIVE).
ENTROPIC_EXPORT const std::atomic< bool > * current_run_cancel()
The cancel token of the run executing on this thread, if any.
Definition run_scope.cpp:37
@ optional
optional: every escape asks the host's path approver
ENTROPIC_EXPORT bool emit_to_current_run_stream(const char *chunk, size_t len)
Deliver a chunk to the stream sink published on THIS thread.
ENTROPIC_EXPORT bool current_run_cancelled()
Whether THIS thread's run has been cancelled.
Definition run_scope.cpp:45
ENTROPIC_EXPORT std::string current_run_session()
The session key of the run executing on this thread (gh#166).
Definition run_scope.cpp:95
ENTROPIC_EXPORT bool cancel_current_run()
Cancel the run executing on this thread (gh#158).
Definition run_scope.cpp:68
void(*)(const char *chunk, size_t len, void *user_data) RunStreamFn
Signature of a run's stream-chunk sink (gh#208, v2.14.2).
Definition run_scope.h:185