37class runnable :
public ucom::object<ant::IRunnable, flash::IRunnable, ANT_INTERFACE, FLASH_OR_ANT_INTERFACE>
39 static_assert(std::disjunction_v<
43 std::is_bind_expression<std::decay_t<CALLABLE>>,
44 std::is_invocable_r<tResult, std::decay_t<CALLABLE>>,
45 std::is_invocable_r<tResult, std::decay_t<CALLABLE>,
tNanoSeconds>,
46 std::is_invocable_r<tResult, std::decay_t<CALLABLE>, tTimeStamp>,
48 std::decay_t<CALLABLE>,
53 "Instantiation of runnable requires a callable with a compatible signature: "
54 "tResult(void) or tResult(tNanoSeconds) or tResult(tTimeStamp) or "
55 "tResult(tNanoSeconds, ant::IRunnable::tActivationType, const void*, size_t)");
57 static_assert(std::is_base_of_v<ant::IRunnable, ANT_INTERFACE>,
58 "ANT_INTERFACE template parameter at runnable<DEFAULT_ACTIVATION_TYPE, ANT_INTERFACE, "
59 "FLASH_OR_ANT_INTERFACE, CALLABLE> must be derived from ant::IRunnable");
61 static_assert(std::is_base_of_v<flash::IRunnable, FLASH_OR_ANT_INTERFACE> ||
62 std::is_base_of_v<ant::IRunnable, FLASH_OR_ANT_INTERFACE>,
63 "FLASH_OR_ANT_INTERFACE template parameter at runnable<DEFAULT_ACTIVATION_TYPE, ANT_INTERFACE, "
64 "FLASH_OR_ANT_INTERFACE, CALLABLE> must be derived from flash::IRunnable or ant::IRunnable");
79 m_fcRunFunc(std::forward<CALLABLE>(fcRunFunc)), m_ui32ActivationType(DEFAULT_ACTIVATION_TYPE)
90 template<
typename CALLABLE_WITH_TIMSTAMP,
91 typename CALLABLE_TYPE = CALLABLE,
93 std::is_invocable_r_v<tResult, std::decay_t<CALLABLE_WITH_TIMSTAMP>, tTimeStamp>,
95 runnable(CALLABLE_WITH_TIMSTAMP&& fcRunFunc)
noexcept:
97 [fcRunFunc = std::forward<CALLABLE_WITH_TIMSTAMP>(fcRunFunc)](
tNanoSeconds tmTrigger)
noexcept ->
tResult
102 m_ui32ActivationType(DEFAULT_ACTIVATION_TYPE)
112 m_fcRunFunc(std::forward<CALLABLE>(fcRunFunc)), m_ui32ActivationType(ui32ActivationType)
134 const void* pvUserData,
135 size_t nUserDataSize)
override
155 const void* pvUserData,
156 size_t nUserDataSize)
override
161 const void*,
size_t>)
163 RETURN_IF_FAILED(
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;
201 return m_ui32ActivationType;
215template<
typename CALLABLE,
typename... ARGS>
243#define ADTF_RUN_FUNCTION(_fcName_) \
244 [this](tTimeStamp tmTime) -> tResult \
246 return _fcName_(tmTime); \
254#define ADTF_RUN_FUNCTION_NS(_fcName_) \
255 [this](adtf::base::flash::tNanoSeconds tmTime) -> tResult \
257 return _fcName_(tmTime); \
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:775
#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:199
runnable(CALLABLE &&fcRunFunc) noexcept
Definition runnable.h:78
std::decay_t< CALLABLE > m_fcRunFunc
Definition runnable.h:68
runnable(CALLABLE &&fcRunFunc, ant::IRunnable::tActivationType ui32ActivationType) noexcept
Definition runnable.h:111
tResult Run(tTimeStamp tmTimeofActivation, ant::IRunnable::tActivationType ui32ActivationType, const void *pvUserData, size_t nUserDataSize) override
Definition runnable.h:132
~runnable() override=default
tResult Run(tNanoSeconds tmTimeofActivation, ant::IRunnable::tActivationType ui32ActivationType, const void *pvUserData, size_t nUserDataSize) override
Definition runnable.h:153
runnable(CALLABLE_WITH_TIMSTAMP &&fcRunFunc) noexcept
Definition runnable.h:95
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:235
constexpr bool always_false
helper template to get a always false expression.
Definition adtf_base_type_traits.h:23
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