StopStrategy.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4
8
10 std::shared_ptr<ScenarioManager::Data_Structure::ApplicationInstance>;
11
13{
14 using ApplicationInstancePtr = std::shared_ptr<ApplicationInstance>;
15}
16
18{
20 typedef std::shared_ptr<ApplicationStopper> ApplicationStopperPtr;
21
22 /**
23 * @class StopStrategy
24 * @ingroup exec
25 * @brief Interface for classes that define how an application get stopped.
26 */
28 {
29 protected:
31
32 /**
33 * How long to wait for a signalled process to actually disappear before giving up.
34 */
35 static constexpr std::chrono::milliseconds TerminationTimeout{10000};
36
37 /**
38 * Waits until the process that was signalled has terminated, then clears the application's
39 * pid.
40 *
41 * A stop is only finished once the process is really gone. Returning earlier would let a
42 * directly following start race with a process that is still shutting down, and would make
43 * the status poller and the stopper fight over the pid and the cached pid file.
44 *
45 * @param application the application that was signalled.
46 * @param signalledPid the pid that was signalled, or -1 if nothing was signalled.
47 */
49 int signalledPid);
50
51 public:
53
54 /**
55 * Stops an application. Implement this method to define the behaviour when stopping applications.
56 * @param application application to be stopped.
57 */
58 virtual void stop(Data_Structure::ApplicationInstancePtr application) = 0;
59 };
60
61 using StopStrategyPtr = std::shared_ptr<StopStrategy>;
62} // namespace ScenarioManager::Exec
std::shared_ptr< ScenarioManager::Data_Structure::ApplicationInstance > ApplicationInstancePtr
Definition StopStrategy.h:9
Interface for classes that handle how application get stopped and killed.
void awaitTermination(const Data_Structure::ApplicationInstancePtr &application, int signalledPid)
Waits until the process that was signalled has terminated, then clears the application's pid.
static constexpr std::chrono::milliseconds TerminationTimeout
How long to wait for a signalled process to actually disappear before giving up.
virtual void stop(Data_Structure::ApplicationInstancePtr application)=0
Stops an application.
StopStrategy(ApplicationStopperPtr stopper)
std::shared_ptr< ApplicationInstance > ApplicationInstancePtr
std::shared_ptr< ApplicationStopper > ApplicationStopperPtr
std::shared_ptr< StopStrategy > StopStrategyPtr
Definition Executor.h:48