distortos  v0.4.0
object-oriented C++ RTOS for microcontrollers
SoftwareTimerControlBlock.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_INTERNAL_SCHEDULER_SOFTWARETIMERCONTROLBLOCK_HPP_
13 #define INCLUDE_DISTORTOS_INTERNAL_SCHEDULER_SOFTWARETIMERCONTROLBLOCK_HPP_
14 
16 
17 namespace distortos
18 {
19 
20 class SoftwareTimer;
21 
22 namespace internal
23 {
24 
25 class SoftwareTimerSupervisor;
26 
29 {
30 public:
31 
33  using FunctionRunner = void(SoftwareTimer&);
34 
42  constexpr SoftwareTimerControlBlock(FunctionRunner& functionRunner, SoftwareTimer& owner) :
44  period_{},
45  functionRunner_{functionRunner},
46  owner_{owner}
47  {
48 
49  }
50 
58  {
59  stop();
60  }
61 
66  bool isRunning() const
67  {
68  return node.isLinked() != false || period_ != decltype(period_){};
69  }
70 
79  void run(SoftwareTimerSupervisor& supervisor);
80 
89  void start(SoftwareTimerSupervisor& supervisor, TickClock::time_point timePoint, TickClock::duration period);
90 
95  void stop();
96 
99  const SoftwareTimerControlBlock& operator=(const SoftwareTimerControlBlock&) = delete;
101 
102 private:
103 
112  void startInternal(SoftwareTimerSupervisor& supervisor, TickClock::time_point timePoint);
113 
118  void stopInternal();
119 
122 
125 
128 };
129 
130 } // namespace internal
131 
132 } // namespace distortos
133 
134 #endif // INCLUDE_DISTORTOS_INTERNAL_SCHEDULER_SOFTWARETIMERCONTROLBLOCK_HPP_
SoftwareTimerListNode class is a base for SoftwareTimerControlBlock that serves as a node in intrusiv...
Definition: SoftwareTimerListNode.hpp:32
FunctionRunner & functionRunner_
reference to runner for software timer's function
Definition: SoftwareTimerControlBlock.hpp:124
void startInternal(SoftwareTimerSupervisor &supervisor, TickClock::time_point timePoint)
Starts the timer - internal version, with no interrupt masking, no stopping and no configuration of p...
Definition: SoftwareTimerControlBlock.cpp:61
TickClock::duration period_
period used to restart repetitive software timer, 0 for one-shot software timers
Definition: SoftwareTimerControlBlock.hpp:121
SoftwareTimer & owner_
reference to SoftwareTimer object that owns this SoftwareTimerControlBlock
Definition: SoftwareTimerControlBlock.hpp:127
void run(SoftwareTimerSupervisor &supervisor)
Runs software timer's function.
Definition: SoftwareTimerControlBlock.cpp:29
SoftwareTimerListNode class header.
std::chrono::time_point< TickClock > time_point
basic time_point type of clock
Definition: TickClock.hpp:42
void stopInternal()
Stops the timer - internal version, with no interrupt masking.
Definition: SoftwareTimerControlBlock.cpp:68
constexpr SoftwareTimerControlBlock(FunctionRunner &functionRunner, SoftwareTimer &owner)
SoftwareTimerControlBlock&#39;s constructor.
Definition: SoftwareTimerControlBlock.hpp:42
void(SoftwareTimer &) FunctionRunner
type of runner for software timer&#39;s function
Definition: SoftwareTimerControlBlock.hpp:33
Top-level namespace of distortos project.
estd::IntrusiveListNode node
node for intrusive list
Definition: SoftwareTimerListNode.hpp:57
bool isLinked() const
Definition: IntrusiveList.hpp:127
void start(SoftwareTimerSupervisor &supervisor, TickClock::time_point timePoint, TickClock::duration period)
Starts the timer.
Definition: SoftwareTimerControlBlock.cpp:40
std::chrono::duration< rep, period > duration
basic duration type of clock
Definition: TickClock.hpp:39
void stop()
Stops the timer.
Definition: SoftwareTimerControlBlock.cpp:50
SoftwareTimerSupervisor class is a supervisor of software timers.
Definition: SoftwareTimerSupervisor.hpp:24
~SoftwareTimerControlBlock()
SoftwareTimerControlBlock&#39;s destructor.
Definition: SoftwareTimerControlBlock.hpp:57
SoftwareTimerControlBlock class is a control block of software timer.
Definition: SoftwareTimerControlBlock.hpp:28
bool isRunning() const
Definition: SoftwareTimerControlBlock.hpp:66
SoftwareTimer class is an abstract interface for software timers.
Definition: SoftwareTimer.hpp:26