ADTF
Loading...
Searching...
No Matches
kernel_thread.h
Go to the documentation of this file.
1
7#pragma once
9
10namespace adtf
11{
12
13namespace system
14{
15
21{
22 private:
23 friend class cKernelThreadHelperRunnable;
24 struct ImplBase;
25 typedef std::shared_ptr<ImplBase> shared_base_type;
26
27 struct ImplBase
28 {
30 shared_base_type pThisPtr;
31 inline virtual ~ImplBase() {}
32 virtual void Run() = 0;
33 };
34
35 template<typename Callable>
36 struct Impl : public ImplBase
37 {
38 Callable pFunc;
39
40 Impl(Callable&& pFunc) : pFunc(std::forward<Callable>(pFunc))
41 {
42 }
43
44 void Run()
45 {
46 pFunc();
47 }
48 };
49
50 template<typename Callable>
51 std::shared_ptr<Impl<Callable>> MakeCallable(Callable&& pFunc)
52 {
53 return std::make_shared<Impl<Callable>>(std::forward<Callable>(pFunc));
54 }
55
56 shared_base_type m_pCallable;
57
58 public:
64
65 kernel_thread(const kernel_thread&) = delete;
66
71
75 template<typename Callable, typename ...Args>
76 kernel_thread(const adtf::services::IKernel::tSchedulingInfo& sScheduling, const char* strName,
77 Callable&& pFunc, Args&&... args): kernel_thread()
78 {
79 m_pCallable = MakeCallable(std::bind(std::forward<Callable>(pFunc),
80 std::forward<Args>(args)...));
81 Create(strName, sScheduling);
82 }
83
87 template<typename Callable, typename ...Args>
88 kernel_thread(const char* strName, Callable&& pFunc, Args&&... args):
89 kernel_thread(adtf::services::IKernel::tSchedulingInfo(), strName,
90 std::forward<Callable>(pFunc),
91 std::forward<Args>(args)...)
92 {
93 }
94
99
106
111 void Swap(kernel_thread& oOther);
112
117 bool Joinable() const;
118
126 tResult Join(tTimeStamp nTimeout = -1);
127
134
141
148
153 bool IsCurrentThread() const;
154
155 private:
156 tResult Create(const char* strName, const adtf::services::IKernel::tSchedulingInfo& sScheduling);
157};
158
159}
160
161}
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
kernel_thread(kernel_thread &&)
tResult GetScheduling(adtf::services::IKernel::tSchedulingInfo &sScheduling) const
tResult Join(tTimeStamp nTimeout=-1)
tResult SetScheduling(const adtf::services::IKernel::tSchedulingInfo &sScheduling)
kernel_thread & operator=(kernel_thread &&oOther)
void Swap(kernel_thread &oOther)
kernel_thread(const char *strName, Callable &&pFunc, Args &&... args)
Definition kernel_thread.h:88
kernel_thread(const adtf::services::IKernel::tSchedulingInfo &sScheduling, const char *strName, Callable &&pFunc, Args &&... args)
Definition kernel_thread.h:76
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