37class runnable :
public ucom::object<ant::IRunnable, flash::IRunnable, ANT_INTERFACE, FLASH_OR_ANT_INTERFACE>
39 static_assert(std::disjunction_v<
42 std::is_bind_expression<std::decay_t<CALLABLE>>,
43 std::is_invocable_r<tResult, std::decay_t<CALLABLE>>,
44 std::is_invocable_r<tResult, std::decay_t<CALLABLE>,
tNanoSeconds>,
45 std::is_invocable_r<tResult, std::decay_t<CALLABLE>, tTimeStamp>,
47 std::decay_t<CALLABLE>,
52 "Instantiation of runnable requires a callable with a compatible signature: "
53 "tResult(void) or tResult(tNanoSeconds) or tResult(tTimeStamp) or "
54 "tResult(tNanoSeconds, ant::IRunnable::tActivationType, const void*, size_t)");
56 static_assert(std::is_base_of_v<ant::IRunnable, ANT_INTERFACE>,
57 "ANT_INTERFACE template parameter at runnable<DEFAULT_ACTIVATION_TYPE, ANT_INTERFACE, "
58 "FLASH_OR_ANT_INTERFACE, CALLABLE> must be derived from ant::IRunnable");
60 static_assert(std::is_base_of_v<flash::IRunnable, FLASH_OR_ANT_INTERFACE> ||
61 std::is_base_of_v<ant::IRunnable, FLASH_OR_ANT_INTERFACE>,
62 "FLASH_OR_ANT_INTERFACE template parameter at runnable<DEFAULT_ACTIVATION_TYPE, ANT_INTERFACE, "
63 "FLASH_OR_ANT_INTERFACE, CALLABLE> must be derived from flash::IRunnable or ant::IRunnable");
78 m_fcRunFunc(std::forward<CALLABLE>(fcRunFunc)), m_ui32ActivationType(DEFAULT_ACTIVATION_TYPE)
89 template<
typename CALLABLE_WITH_TIMSTAMP,
90 typename CALLABLE_TYPE = CALLABLE,
92 std::is_invocable_r_v<tResult, std::decay_t<CALLABLE_WITH_TIMSTAMP>, tTimeStamp>,
94 runnable(CALLABLE_WITH_TIMSTAMP&& fcRunFunc)
noexcept:
96 [fcRunFunc = std::forward<CALLABLE_WITH_TIMSTAMP>(fcRunFunc)](
tNanoSeconds tmTrigger)
noexcept ->
tResult
101 m_ui32ActivationType(DEFAULT_ACTIVATION_TYPE)
111 m_fcRunFunc(std::forward<CALLABLE>(fcRunFunc)), m_ui32ActivationType(ui32ActivationType)
133 const void* pvUserData,
134 size_t nUserDataSize)
override
154 const void* pvUserData,
155 size_t nUserDataSize)
override
159 tResult oResult = ERR_NOT_INITIALIZED;
161 const void*,
size_t>)
163 oResult =
m_fcRunFunc(tmTimeofActivation, ui32ActivationType, pvUserData, nUserDataSize);
165 else if constexpr (std::is_invocable_r_v<tResult, CALLABLE, tTimeStamp>)
168 (void) nUserDataSize;
171 else if constexpr (std::is_invocable_r_v<tResult, CALLABLE, tNanoSeconds>)
174 (void) nUserDataSize;
177 else if constexpr (std::is_invocable_r_v<tResult, CALLABLE>)
179 (void) tmTimeofActivation;
180 (void) ui32ActivationType;
182 (void) nUserDataSize;
185 RETURN_IF_FAILED(oResult);
197 return m_ui32ActivationType;
211template<
typename CALLABLE,
typename... ARGS>
239#define ADTF_RUN_FUNCTION(_fcName_) \
240 [this](tTimeStamp tmTime) -> tResult \
242 return _fcName_(tmTime); \
250#define ADTF_RUN_FUNCTION_NS(_fcName_) \
251 [this](adtf::base::flash::tNanoSeconds tmTime) -> tResult \
253 return _fcName_(tmTime); \
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
Definition result.h:42
Definition runnable_intf.h:27
std::function< tResult(tTimeStamp)> tRunFunction
Type definition of the function used to implement Run.
Definition runnable_intf.h:38
tActivationType
Definition runnable_intf.h:45
@ RUN_UNSPECIFIED
unspecified Run activation type.
Definition runnable_intf.h:47
Definition runnable_intf.h:112
std::function< tResult(tNanoSeconds)> tRunFunction
Type definition of the function used to implement Run.
Definition runnable_intf.h:123
ant::IRunnable::tActivationType GetActivationType() const override
Definition runnable.h:195
runnable(CALLABLE &&fcRunFunc) noexcept
Definition runnable.h:77
std::decay_t< CALLABLE > m_fcRunFunc
Definition runnable.h:67
runnable(CALLABLE &&fcRunFunc, ant::IRunnable::tActivationType ui32ActivationType) noexcept
Definition runnable.h:110
tResult Run(tTimeStamp tmTimeofActivation, ant::IRunnable::tActivationType ui32ActivationType, const void *pvUserData, size_t nUserDataSize) override
Definition runnable.h:131
~runnable() override=default
tResult Run(tNanoSeconds tmTimeofActivation, ant::IRunnable::tActivationType ui32ActivationType, const void *pvUserData, size_t nUserDataSize) override
Definition runnable.h:152
runnable(CALLABLE_WITH_TIMSTAMP &&fcRunFunc) noexcept
Definition runnable.h:94
Namespace for all functionality of the ADTF Base SDK provided since v3.0.
Definition adtf_class_version.h:16
adtf::base::runnable< DEFAULT_ACTIVATION_TYPE, ANT_INTERFACE, flash::IRunnable, CALLABLE > runnable
Definition runnable.h:231
Namespace for the ADTF Base SDK.
Definition adtf_base_type_traits.h:13
runnable(CALLABLE &&, ARGS &&...) -> runnable< ant::IRunnable::RUN_UNSPECIFIED, ant::IRunnable, flash::IRunnable, CALLABLE && >
DestinationTimeStamp duration_cast(const SourceTimeStamp &) noexcept
Duration cast base template to converted between different time resolution.
Definition chrono.h:155
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14
A timestamp with nanosecond precision.
Definition chrono.h:23