75 std::shared_ptr<std::thread> thread_pool =
nullptr;
88 std::chrono::milliseconds timeout { 0 };
130 template <
typename T>
133 execution_metadata[std::move(key)] = std::forward<T>(value);
147 template <
typename T>
148 CastResult<T>
get(
const std::string& key)
const
150 auto it = execution_metadata.find(key);
152 if (it == execution_metadata.end()) {
153 CastResult<T> result;
154 result.error =
"ExecutionContext missing key: " + key;
158 return safe_any_cast<T>(it->second);
169 template <
typename T>
170 T
get_or(
const std::string& key,
const T& default_value)
const
172 auto it = execution_metadata.find(key);
174 if (it == execution_metadata.end())
175 return default_value;
177 return safe_any_cast<T>(it->second).value_or(default_value);
191 template <
typename T>
194 auto it = execution_metadata.find(key);
196 if (it == execution_metadata.end())
197 throw std::runtime_error(
"ExecutionContext missing key: " + key);
199 return safe_any_cast_or_throw<T>(it->second);
210 return execution_metadata.contains(key);
223 template <
typename T>
226 dependencies.emplace_back(
typeid(T));
242 pre_execution_hook = std::move(cb);
254 post_execution_hook = std::move(cb);
266 reconstruction_callback = std::move(cb);
std::optional< double > duration
@ 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.