ADTF  3.18.2
kernel_thread_loop.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include "kernel_thread.h"
9 
10 
11 namespace adtf
12 {
13 
14 namespace system
15 {
16 
21 class kernel_thread_looper: public kernel_thread, public adtf_util::cLooper
22 {
23  public:
24  kernel_thread_looper() = default;
25 
27 
28  template<typename ...Args>
29  kernel_thread_looper(const char* strName, Args&&... args): cLooper(std::forward<Args>(args)...)
30  {
31  *static_cast<kernel_thread*>(this) = kernel_thread(strName, GetCallable());
32  }
33 
34  template<typename ...Args>
36  const char* strName, Args&&... args): cLooper(std::forward<Args>(args)...)
37  {
38  *static_cast<kernel_thread*>(this) = kernel_thread(sScheduling, strName, GetCallable());
39  }
40 
42  kernel_thread(static_cast<kernel_thread&&>(oOther)),
43  cLooper(static_cast<cLooper&&>(oOther))
44  {
45  }
46 
47  kernel_thread_looper& operator=(kernel_thread_looper&& oOther)
48  {
49  kernel_thread::Swap(oOther);
50  cLooper::Swap(oOther);
51  return *this;
52  }
53 };
54 
61 {
62  private:
63  kernel_thread_looper m_oLooper;
64  bool m_bSelfDestruct;
65 
66  public:
67  using tLoopState = adtf_util::cLooper::tLoopState;
68 
72  virtual ~cKernelThreadLoop();
73 
85  tResult Create(const char *strName, const adtf::services::IKernel::tSchedulingInfo &sScheduling =
86  adtf::services::IKernel::tSchedulingInfo(), bool bSelfDestruct = false,
87  tLoopState eInitialState = tLoopState::Running);
88 
96 
101  tLoopState GetState();
102 
109  tResult SetState(tLoopState eState, bool bWaitForAck = true);
110 
111  private:
112  void Loop();
113 
114  private:
115  void SelfDestruct();
116 
117  protected:
123  virtual tResult LoopFunc() = 0;
124 };
125 
126 }
127 
128 }
The Kernel Thread Loop class provides a thread that repeatedly calls the LoopFunc method.
virtual ~cKernelThreadLoop()
Destructor.
tResult Create(const char *strName, const adtf::services::IKernel::tSchedulingInfo &sScheduling=adtf::services::IKernel::tSchedulingInfo(), bool bSelfDestruct=false, tLoopState eInitialState=tLoopState::Running)
Creates the thread that executes the LoopFunc method.
virtual tResult LoopFunc()=0
Implement this method.
tResult Release()
Destroys the thread.
tResult SetState(tLoopState eState, bool bWaitForAck=true)
Changes the state of the internal looper.
tLoopState GetState()
Retrieves the current state of the looper.
Convenience class that combines the functionality of a kernel_thread and an A_UTILS_NS::cLooper.
Class that manages a kernel thread.
Definition: kernel_thread.h:21
void Swap(kernel_thread &oOther)
Swaps two threads.
kernel_thread()
Default constructor.
Copyright © Audi Electronics Venture GmbH.
Namespace for entire ADTF SDK.
Struct for defining scheduling settings of a thread or timer.
Definition: kernel_intf.h:82