ADTF
Loading...
Searching...
No Matches
kernel_timer.h
Go to the documentation of this file.
1
7#pragma once
9
10namespace adtf
11{
12
13namespace system
14{
15
20{
21 private:
22 friend class cKernelTimerHelperRunnable;
23 struct ImplBase;
24 typedef std::shared_ptr<ImplBase> shared_base_type;
25
26 struct ImplBase
27 {
29 inline virtual ~ImplBase() {}
30 virtual void Run() = 0;
31 };
32
33 template<typename Callable>
34 struct Impl : public ImplBase
35 {
36 Callable pFunc;
37
38 Impl(Callable&& pFunc) : pFunc(std::forward<Callable>(pFunc))
39 {
40 }
41
42 void Run()
43 {
44 pFunc();
45 }
46 };
47
48 template<typename Callable>
49 std::shared_ptr<Impl<Callable>> MakeCallable(Callable&& pFunc)
50 {
51 return std::make_shared<Impl<Callable>>(std::forward<Callable>(pFunc));
52 }
53
54 shared_base_type m_pCallable;
55
56 public:
61
62 kernel_timer(const kernel_timer&) = delete;
63
68
72 template<typename Callable, typename ...Args>
75 const char* strName,
76 tTimeStamp tmPeriod, tTimeStamp tmInitialDelay,
77 Callable&& pFunc, Args&&... args): kernel_timer()
78 {
79 m_pCallable = MakeCallable(std::bind(std::forward<Callable>(pFunc),
80 std::forward<Args>(args)...));
81 Create(strName, sScheduling, eClock, tmPeriod, tmInitialDelay);
82 }
83
87 template<typename Callable, typename ...Args>
88 kernel_timer(tTimeStamp tmMaximumExectionTime,
91 const char* strName,
92 tTimeStamp tmPeriod, tTimeStamp tmInitialDelay, uint32_t nFlags,
93 Callable&& pFunc, Args&&... args): kernel_timer()
94 {
95 m_pCallable = MakeCallable(std::bind(std::forward<Callable>(pFunc),
96 std::forward<Args>(args)...));
97 Create(strName, sScheduling, eClock, tmPeriod, tmInitialDelay, tmMaximumExectionTime, nFlags);
98 }
99
103 template<typename Callable, typename ...Args>
104 kernel_timer(const char* strName, tTimeStamp tmPeriod, tTimeStamp tmInitialDelay,
105 Callable&& pFunc, Args&&... args):
106 kernel_timer(adtf::services::IKernel::tTimerClock::ADTF,
107 adtf::services::IKernel::tSchedulingInfo(), strName,
108 tmPeriod, tmInitialDelay,
109 std::forward<Callable>(pFunc),
110 std::forward<Args>(args)...)
111 {
112 }
113
119
126
131 void Swap(kernel_timer& oOther);
132
137 bool Stoppable() const;
138
145
152
159
160 private:
161 tResult Create(const char* strName, const adtf::services::IKernel::tSchedulingInfo& sScheduling,
162 adtf::services::IKernel::tTimerClock eClock, tTimeStamp tmPeriod,
163 tTimeStamp tmInitialDelay);
164
165 tResult Create(const char* strName, const adtf::services::IKernel::tSchedulingInfo& sScheduling,
166 adtf::services::IKernel::tTimerClock eClock, tTimeStamp tmPeriod,
167 tTimeStamp tmInitialDelay, tTimeStamp tmMaximumExecutionTime, uint32_t nFlags);
168};
169
170}
171
172}
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
tTimerClock
Definition kernel_intf.h:60
kernel_timer(adtf::services::IKernel::tTimerClock eClock, const adtf::services::IKernel::tSchedulingInfo &sScheduling, const char *strName, tTimeStamp tmPeriod, tTimeStamp tmInitialDelay, Callable &&pFunc, Args &&... args)
Definition kernel_timer.h:73
kernel_timer & operator=(kernel_timer &&oOther)
void Swap(kernel_timer &oOther)
kernel_timer(kernel_timer &&)
tResult SetScheduling(const adtf::services::IKernel::tSchedulingInfo &sScheduling)
kernel_timer(tTimeStamp tmMaximumExectionTime, adtf::services::IKernel::tTimerClock eClock, const adtf::services::IKernel::tSchedulingInfo &sScheduling, const char *strName, tTimeStamp tmPeriod, tTimeStamp tmInitialDelay, uint32_t nFlags, Callable &&pFunc, Args &&... args)
Definition kernel_timer.h:88
tResult GetScheduling(adtf::services::IKernel::tSchedulingInfo &sScheduling) const
kernel_timer(const char *strName, tTimeStamp tmPeriod, tTimeStamp tmInitialDelay, Callable &&pFunc, Args &&... args)
Definition kernel_timer.h:104
Definition object_ptr.h:384
Namespace for a summary of all service interfaces provided by ADTF.
Definition rpc_object_server_registry_intf.h:80
Namespace for the ADTF System SDK.
Definition adtf_service.h:14
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14