distortos  v0.5.0
object-oriented C++ RTOS for microcontrollers
SignalsReceiverControlBlock.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_INTERNAL_SYNCHRONIZATION_SIGNALSRECEIVERCONTROLBLOCK_HPP_
13 #define INCLUDE_DISTORTOS_INTERNAL_SYNCHRONIZATION_SIGNALSRECEIVERCONTROLBLOCK_HPP_
14 
16 
17 #if CONFIG_SIGNALS_ENABLE == 1
18 
19 #include "distortos/SignalSet.hpp"
20 
21 #include <cstdint>
22 
23 union sigval;
24 
25 namespace distortos
26 {
27 
28 class SignalAction;
29 class SignalInformation;
30 class SignalInformationQueueWrapper;
31 class SignalsCatcher;
32 
33 namespace internal
34 {
35 
36 class SignalInformationQueue;
37 class SignalsCatcherControlBlock;
38 class ThreadControlBlock;
39 
42 {
43 public:
44 
54  explicit SignalsReceiverControlBlock(SignalInformationQueueWrapper* signalInformationQueueWrapper,
55  SignalsCatcher* signalsCatcher);
56 
72  std::pair<int, SignalInformation> acceptPendingSignal(uint8_t signalNumber);
73 
85  int deliveryOfSignalsStartedHook() const;
86 
104  int generateSignal(uint8_t signalNumber, ThreadControlBlock& threadControlBlock);
105 
111 
125  std::pair<int, SignalAction> getSignalAction(uint8_t signalNumber) const;
126 
135  SignalSet getSignalMask() const;
136 
158  int queueSignal(uint8_t signalNumber, sigval value, ThreadControlBlock& threadControlBlock) const;
159 
176  std::pair<int, SignalAction> setSignalAction(uint8_t signalNumber, const SignalAction& signalAction);
177 
190  int setSignalMask(SignalSet signalMask, bool deliver);
191 
196  void setWaitingSignalSet(const SignalSet* const signalSet)
197  {
198  waitingSignalSet_ = signalSet;
199  }
200 
201 private:
202 
214  void afterGenerateQueueLocked(uint8_t signalNumber, ThreadControlBlock& threadControlBlock) const;
215 
224  void afterGenerateQueueUnlocked(uint8_t signalNumber, ThreadControlBlock& threadControlBlock) const;
225 
238  int beforeGenerateQueue(uint8_t signalNumber, ThreadControlBlock& threadControlBlock) const;
239 
253  std::pair<int, bool> isSignalIgnored(uint8_t signalNumber) const;
254 
257 
260 
263 
266 };
267 
268 } // namespace internal
269 
270 } // namespace distortos
271 
272 #endif // CONFIG_SIGNALS_ENABLE == 1
273 
274 #endif // INCLUDE_DISTORTOS_INTERNAL_SYNCHRONIZATION_SIGNALSRECEIVERCONTROLBLOCK_HPP_
Definition: signal.h:28
std::pair< int, SignalAction > setSignalAction(uint8_t signalNumber, const SignalAction &signalAction)
Sets association for given signal number.
Definition: SignalsReceiverControlBlock.cpp:164
ThreadControlBlock class is a simple description of a Thread.
Definition: ThreadControlBlock.hpp:40
SignalsCatcherControlBlock class is a structure required by threads for "catching" and "handling" of ...
Definition: SignalsCatcherControlBlock.hpp:33
SignalsReceiverControlBlock(SignalInformationQueueWrapper *signalInformationQueueWrapper, SignalsCatcher *signalsCatcher)
SignalsReceiverControlBlock&#39;s constructor.
Definition: SignalsReceiverControlBlock.cpp:36
void setWaitingSignalSet(const SignalSet *const signalSet)
Definition: SignalsReceiverControlBlock.hpp:196
SignalInformationQueue * signalInformationQueue_
pointer to SignalInformationQueue for this receiver, nullptr if this receiver cannot queue signals ...
Definition: SignalsReceiverControlBlock.hpp:265
SignalSet class header.
int deliveryOfSignalsStartedHook() const
Hook function executed when delivery of signals is started.
Definition: SignalsReceiverControlBlock.cpp:68
SignalsReceiverControlBlock class is a structure required by threads for "receiving" of signals...
Definition: SignalsReceiverControlBlock.hpp:41
void afterGenerateQueueUnlocked(uint8_t signalNumber, ThreadControlBlock &threadControlBlock) const
Actions executed out of critical section after signal is generated with generateSignal() or queued wi...
Definition: SignalsReceiverControlBlock.cpp:220
std::pair< int, SignalInformation > acceptPendingSignal(uint8_t signalNumber)
Accepts (clears) one of signals that are pending.
Definition: SignalsReceiverControlBlock.cpp:50
int setSignalMask(SignalSet signalMask, bool deliver)
Sets signal mask for associated thread.
Definition: SignalsReceiverControlBlock.cpp:184
SignalsCatcherControlBlock * signalsCatcherControlBlock_
pointer to SignalsCatcherControlBlock for this receiver, nullptr if this receiver cannot catch/handle...
Definition: SignalsReceiverControlBlock.hpp:262
distortos configuration
SignalSet class is used as a set of signals.
Definition: SignalSet.hpp:28
Top-level namespace of distortos project.
SignalSet getSignalMask() const
Gets signal mask for associated thread.
Definition: SignalsReceiverControlBlock.cpp:121
SignalInformationQueue class can be used for queuing of SignalInformation objects.
Definition: SignalInformationQueue.hpp:34
void afterGenerateQueueLocked(uint8_t signalNumber, ThreadControlBlock &threadControlBlock) const
Actions executed from within critical section after signal is generated with generateSignal() or queu...
Definition: SignalsReceiverControlBlock.cpp:197
SignalSet pendingSignalSet_
set of pending signals
Definition: SignalsReceiverControlBlock.hpp:256
std::pair< int, bool > isSignalIgnored(uint8_t signalNumber) const
Checks whether signal is ignored.
Definition: SignalsReceiverControlBlock.cpp:250
const SignalSet * waitingSignalSet_
pointer to set of "waited for" signals, nullptr if associated thread is not waiting for any signals ...
Definition: SignalsReceiverControlBlock.hpp:259
SignalAction class contains information needed to handle signal that was caught.
Definition: SignalAction.hpp:30
SignalInformationQueueWrapper class is a container for internal::SignalInformationQueue.
Definition: SignalInformationQueueWrapper.hpp:32
SignalSet getPendingSignalSet() const
Definition: SignalsReceiverControlBlock.cpp:103
std::pair< int, SignalAction > getSignalAction(uint8_t signalNumber) const
Gets SignalAction associated with given signal number.
Definition: SignalsReceiverControlBlock.cpp:113
int queueSignal(uint8_t signalNumber, sigval value, ThreadControlBlock &threadControlBlock) const
Queues signal for associated thread.
Definition: SignalsReceiverControlBlock.cpp:129
int generateSignal(uint8_t signalNumber, ThreadControlBlock &threadControlBlock)
Generates signal for associated thread.
Definition: SignalsReceiverControlBlock.cpp:77
SignalsCatcher class is a container for internal::SignalsCatcherControlBlock.
Definition: SignalsCatcher.hpp:32
int beforeGenerateQueue(uint8_t signalNumber, ThreadControlBlock &threadControlBlock) const
Actions executed before signal is generated with generateSignal() or queued with queueSignal().
Definition: SignalsReceiverControlBlock.cpp:235