distortos  v0.7.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  asm("" ::: "memory"); // required for LTO
69  return node.isLinked() != false || period_ != decltype(period_){};
70  }
71 
80  void run(SoftwareTimerSupervisor& supervisor);
81 
90  void start(SoftwareTimerSupervisor& supervisor, TickClock::time_point timePoint, TickClock::duration period);
91 
96  void stop();
97 
100  const SoftwareTimerControlBlock& operator=(const SoftwareTimerControlBlock&) = delete;
102 
103 private:
104 
113  void startInternal(SoftwareTimerSupervisor& supervisor, TickClock::time_point timePoint);
114 
119  void stopInternal();
120 
123 
126 
129 };
130 
131 } // namespace internal
132 
133 } // namespace distortos
134 
135 #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:125
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:122
SoftwareTimer & owner_
reference to SoftwareTimer object that owns this SoftwareTimerControlBlock
Definition: SoftwareTimerControlBlock.hpp:128
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's constructor.
Definition: SoftwareTimerControlBlock.hpp:42
void(SoftwareTimer &) FunctionRunner
type of runner for software timer's function
Definition: SoftwareTimerControlBlock.hpp:33
Top-level namespace of distortos project.
Definition: buttons.hpp:33
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'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