7 #ifndef _ADTF_UCOM_ANT_TESTING_RUNTIME_INCLUDES_HEADER_
8 #define _ADTF_UCOM_ANT_TESTING_RUNTIME_INCLUDES_HEADER_
92 int8_t nServiceLevel);
105 int8_t nServiceLevel);
119 std::thread m_oThread;
120 std::mutex m_oActionMutex;
121 typedef std::function<void()> action_type;
122 action_type m_fnAction;
123 bool m_bQuitThread =
false;
124 std::condition_variable m_oNewAction;
129 m_oThread = std::thread([&]
131 std::unique_lock<std::mutex> oLocker(m_oActionMutex);
134 m_oNewAction.wait(oLocker, [&]
136 return m_fnAction || m_bQuitThread;
145 m_fnAction = action_type();
153 std::lock_guard<std::mutex> oLocker(m_oActionMutex);
154 m_bQuitThread =
true;
157 m_oNewAction.notify_one();
163 std::promise<tResult> oPromisedResult;
164 auto oResult = oPromisedResult.get_future();
167 std::lock_guard<std::mutex> oLocker(m_oActionMutex);
170 oPromisedResult.set_value(fnAction());
174 m_oNewAction.notify_one();
175 return oResult.get();
183 template<
typename RuntimeClass>
187 std::unique_ptr<RuntimeClass> m_pRuntime;
191 m_pRuntime(
new RuntimeClass)
202 tResult Exec(std::function<
void()> fnStartup)
213 template<
typename ExecuteForward>
217 std::unique_ptr<ExecuteForward> m_pExecuteForward;
218 std::thread m_oExecWaitThread;
223 if (m_oExecWaitThread.joinable())
225 m_oExecWaitThread.join();
231 return Execute([&]() ->
tResult
233 m_pExecuteForward.reset(
new ExecuteForward());
240 if (m_oExecWaitThread.joinable())
245 std::promise<tResult> oExecLoopStarted;
246 auto oStarted = oExecLoopStarted.get_future();
247 m_oExecWaitThread = std::thread([&]
251 auto nExecResult = m_pExecuteForward->Exec([&]
253 oExecLoopStarted.set_value(ERR_NOERROR);
258 oExecLoopStarted.set_value(nExecResult);
264 return oStarted.get();
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
#define IS_FAILED(s)
Check if result is failed.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
A common result class usable as return value throughout.
The IRuntime interface controls global system startup and shutdown.
@ RL_Shutdown
The system is shut down.
Definition of a common level based runtime.
This is a helper class that executes calls in a thread.
A testing runtime definition for own applications.
adtf::ucom::ant::runtime< tTestRL::RL_Running > base_type
base type for the testing runtime
This template makes will forward the runtime_executor function calls to the RuntimeClass.
This template makes sure to create and execute an instance of a runtime in a separate thread.
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
void load_service(const adtf_util::cString &strPluginName, const adtf_util::cString &strClassId, const adtf_util::cString &strObjectId, int8_t nPluginLevel, int8_t nServiceLevel)
load plugin and create a service.
const adtf_util::cFilename find_plugin(const adtf::util::cString &strPluginName)
find plugin helper.
tTestRL
A testing runtime runlevel definition for own applications.
void clean_up()
cleans up the current _runtime returns void.
const adtf_util::cFilename load_plugin(const adtf::util::cString &strPluginName, int8_t ui8Level, ucom::ant::IRuntime &oRuntime)
load plugin helper.
Namespace for entire ADTF SDK.
adtf::ucom::IRuntime * _runtime
Global Runtime Pointer to reference to the current runtime.