77 std::shared_ptr<std::thread> thread_pool =
nullptr;
90 std::chrono::milliseconds timeout { 0 };
132 template <
typename T>
135 execution_metadata[std::move(key)] = std::forward<T>(value);
149 template <
typename T>
150 CastResult<T>
get(
const std::string& key)
const
152 auto it = execution_metadata.find(key);
154 if (it == execution_metadata.end()) {
155 CastResult<T> result;
156 result.error =
"ExecutionContext missing key: " + key;
160 return safe_any_cast<T>(it->second);
171 template <
typename T>
172 T
get_or(
const std::string& key,
const T& default_value)
const
174 auto it = execution_metadata.find(key);
176 if (it == execution_metadata.end())
177 return default_value;
179 return safe_any_cast<T>(it->second).value_or(default_value);
193 template <
typename T>
196 auto it = execution_metadata.find(key);
198 if (it == execution_metadata.end())
199 error<std::runtime_error>(Journal::Component::Yantra, Journal::Context::Runtime, std::source_location::current(),
"ExecutionContext missing key: {}", key);
201 return safe_any_cast_or_throw<T>(it->second);
212 return execution_metadata.contains(key);
225 template <
typename T>
228 dependencies.emplace_back(
typeid(T));
244 pre_execution_hook = std::move(cb);
256 post_execution_hook = std::move(cb);
268 reconstruction_callback = std::move(cb);
@ CUSTOM
User-defined analysis types.
std::function< void(std::any &)> OperationHookCallback
Callback type for pre/post operation hooks.
OperationType
Operation categories for organization and discovery.
ExecutionMode
Execution paradigms for operations.
@ SYNC
Synchronous execution.
@ CHAINED
Part of a sequential chain.
@ DEPENDENCY
Part of dependency graph.
@ ASYNC
Asynchronous execution.
@ PARALLEL
Parallel with other operations.
std::function< std::any(std::vector< std::vector< double > > &, std::any &)> ReconstructionCallback
Callback type for custom reconstruction logic.
ExecutionContext & on_reconstruct(ReconstructionCallback cb)
Set reconstruction callback.
std::vector< std::type_index > dependencies
Operation dependencies required before execution.
CastResult< T > get(const std::string &key) const
Retrieve metadata value using safe casting.
ExecutionContext & on_pre(OperationHookCallback cb)
Set pre-execution hook.
ExecutionContext & set_mode(ExecutionMode m)
Set execution mode.
ExecutionContext & with_timeout(std::chrono::milliseconds duration)
Set execution timeout.
bool contains(const std::string &key) const
Check whether a metadata key exists.
T get_or_throw(const std::string &key) const
Retrieve metadata value or throw if unavailable.
std::unordered_map< std::string, std::any > execution_metadata
Arbitrary metadata parameters used by operations.
ExecutionContext & on_post(OperationHookCallback cb)
Set post-execution hook.
T get_or(const std::string &key, const T &default_value) const
Retrieve metadata value or return a default.
ExecutionContext & depends_on()
Register dependency on a specific operation type.
ExecutionContext & set(std::string key, T &&value)
Insert or update metadata value.
Context information controlling how a compute operation executes.