ark::pipeline::Context
Defined in header “ark/pipeline/context.hh”.
A context allows you to register things like callbacks and timers, along with maintain state across a pipeline. It is typically automatically created and managed for you.
This is an internal implementation detail, and not expected to be used by consumers.
Methods
-
Context(Pipeline & pipeline)
Constructs a context, for usage on the given pipeline. -
~Context()
Destructor. Shuts down the context, if it hasn’t already been shutdown. Shutting down may throw, it’s advisable to shutdown yourself. -
void initialize(const TimeProviderFactoryPtr & time_provider_factory, const RuntimesProviderPtr & runtime_provider, PublisherConnectorPtr publisher_connector, const ExecutorStatisticsRetrievalFunction & statistics_retrieval_function, const ExecutorRuntimeControlFunction & runtime_control_function)
Initializes this context, preparing all of the publishers/subscribers/timers to begin execution. This will establish all of the necessary publishers/subscribers, and is typically called by a runner automatically.If you don’t provide a publisher connector, the default publisher connector will be used.
-
void start()
Invokes start() on every stage interface, telling it that it is safe to start all of its threads. -
void interrupt()
Called for the context to interrupt all stages. If the pipeline is ready to shutdown, shutdown will them begin. -
void request_shutdown()
Called for the context to request a shutdown. This sets internal flags such that the main loop in the executor can exit and begin the full shutdown process. -
void shutdown(const std::function< void()> & shutdown_callback)
Shuts down this context, stopping all of the running stages in a controlled fashion. This will throw is any stage throws, but will attempt to shutdown all available stages.The provided thread pool will be destroyed after the stages have been shutdown but before all publishers/subscribers are erased.
-
void set_start_time(const std::chrono::steady_clock::time_point & start_time)
Sets the time that this context is starting at. This is used to understand how much time has elapsed during execution. -
bool shutdown_desired()
Returns true if a shutdown is desired, or false otherwise. -
void poll_shutdown_tokens(const std::chrono::steady_clock::time_point & now)
Polls all the shutdown tokens, checking to see if any of them are ready to shutdown or not. -
bool execution_successful(const std::chrono::steady_clock::time_point & now)
Returns true if the overall execution was successful or not. This is normally set via the shtudown tokens. -
std::optional< std::chrono::nanoseconds > get_time_remaining_until_ready(const std::chrono::steady_clock::time_point & now)
Returns the amount of time remaining until the next timer needs to fire. If there are no timers, this returns an empty optional. -
void tick(const std::chrono::steady_clock::time_point & now)
Ticks the system forward forward. Walks through them and updates them with the given timestamp (assumed to have come from the time provider), and then executes any subscribers that are ready. -
const std::vector< StageInterfacePtr > & stage_interfaces()
Returns all of the stage interfaces. -
std::chrono::steady_clock::time_point preferred_start_time()
Returns the preferred start time, based on what each of the stages has reported. -
ExecutorStartupStatistics startup_statistics()
Returns statistics related to starting up the pipeline.