distortos  v0.5.0
object-oriented C++ RTOS for microcontrollers
SignalsCatcherControlBlock.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_INTERNAL_SYNCHRONIZATION_SIGNALSCATCHERCONTROLBLOCK_HPP_
13 #define INCLUDE_DISTORTOS_INTERNAL_SYNCHRONIZATION_SIGNALSCATCHERCONTROLBLOCK_HPP_
14 
16 
17 #if CONFIG_SIGNALS_ENABLE == 1
18 
20 
21 #include <memory>
22 
23 namespace distortos
24 {
25 
26 namespace internal
27 {
28 
29 class SignalsReceiverControlBlock;
30 class ThreadControlBlock;
31 
34 {
35 public:
36 
38  using Association = std::pair<SignalSet, SignalAction>;
39 
41  using Storage = std::aligned_storage<sizeof(Association), alignof(Association)>::type;
42 
44  using StorageUniquePointer = std::unique_ptr<Storage[], void(&)(Storage*)>;
45 
54  SignalsCatcherControlBlock(StorageUniquePointer&& storageUniquePointer, size_t storageSize);
55 
61 
73  void afterGenerateQueueUnlocked(ThreadControlBlock& threadControlBlock);
74 
90  int beforeGenerateQueue(ThreadControlBlock& threadControlBlock);
91 
101  {
102  deliveryIsPending_ = false;
103  }
104 
115  std::pair<int, SignalAction> getAssociation(uint8_t signalNumber) const;
116 
122  {
123  return signalMask_;
124  }
125 
139  std::pair<int, SignalAction> setAssociation(uint8_t signalNumber, const SignalAction& signalAction);
140 
152  void setSignalMask(SignalSet signalMask, const SignalsReceiverControlBlock* owner);
153 
156  const SignalsCatcherControlBlock& operator=(const SignalsCatcherControlBlock&) = delete;
158 
159 private:
160 
170  SignalAction clearAssociation(uint8_t signalNumber);
171 
182  SignalAction clearAssociation(uint8_t signalNumber, Association& association);
183 
189  {
190  return reinterpret_cast<Association*>(storageUniquePointer_.get());
191  }
192 
205  int requestDeliveryOfSignals(ThreadControlBlock& threadControlBlock);
206 
209 
212 
214  union
215  {
218 
221  };
222 
225 
228 };
229 
230 } // namespace internal
231 
232 } // namespace distortos
233 
234 #endif // CONFIG_SIGNALS_ENABLE == 1
235 
236 #endif // INCLUDE_DISTORTOS_INTERNAL_SYNCHRONIZATION_SIGNALSCATCHERCONTROLBLOCK_HPP_
SignalSet signalMask_
SignalSet with signal mask for associated thread.
Definition: SignalsCatcherControlBlock.hpp:211
void setSignalMask(SignalSet signalMask, const SignalsReceiverControlBlock *owner)
Sets signal mask for associated thread.
Definition: SignalsCatcherControlBlock.cpp:274
Association * associationsEnd_
pointer to "one past the last" element of range of Association objects
Definition: SignalsCatcherControlBlock.hpp:217
ThreadControlBlock class is a simple description of a Thread.
Definition: ThreadControlBlock.hpp:40
std::aligned_storage< sizeof(Association), alignof(Association)>::type Storage
type of uninitialized storage for Association objects
Definition: SignalsCatcherControlBlock.hpp:41
SignalAction clearAssociation(uint8_t signalNumber)
Clears association for given signal number.
Definition: SignalsCatcherControlBlock.cpp:294
SignalsCatcherControlBlock class is a structure required by threads for "catching" and "handling" of ...
Definition: SignalsCatcherControlBlock.hpp:33
std::pair< SignalSet, SignalAction > Association
association of signal numbers (as SignalSet) with SignalAction
Definition: SignalsCatcherControlBlock.hpp:38
SignalsReceiverControlBlock class is a structure required by threads for "receiving" of signals...
Definition: SignalsReceiverControlBlock.hpp:41
Association * getAssociationsBegin() const
Definition: SignalsCatcherControlBlock.hpp:188
SignalAction class header.
int requestDeliveryOfSignals(ThreadControlBlock &threadControlBlock)
Requests delivery of signals to associated thread.
Definition: SignalsCatcherControlBlock.cpp:321
distortos configuration
std::pair< int, SignalAction > getAssociation(uint8_t signalNumber) const
Gets SignalAction associated with given signal number.
Definition: SignalsCatcherControlBlock.cpp:215
void afterGenerateQueueUnlocked(ThreadControlBlock &threadControlBlock)
Part of SignalsReceiverControlBlock::afterGenerateQueueUnlocked() specific to catching unmasked signa...
Definition: SignalsCatcherControlBlock.cpp:194
SignalSet getSignalMask() const
Definition: SignalsCatcherControlBlock.hpp:121
SignalSet class is used as a set of signals.
Definition: SignalSet.hpp:28
Top-level namespace of distortos project.
~SignalsCatcherControlBlock()
SignalsCatcherControlBlock&#39;s destructor.
Definition: SignalsCatcherControlBlock.cpp:189
bool deliveryIsPending_
true if signal delivery is pending, false otherwise
Definition: SignalsCatcherControlBlock.hpp:227
Storage * storageBegin_
pointer to first element of range of Storage objects
Definition: SignalsCatcherControlBlock.hpp:220
std::pair< int, SignalAction > setAssociation(uint8_t signalNumber, const SignalAction &signalAction)
Sets association for given signal number.
Definition: SignalsCatcherControlBlock.cpp:227
StorageUniquePointer storageUniquePointer_
storage for Association objects
Definition: SignalsCatcherControlBlock.hpp:208
std::unique_ptr< Storage[], void(&)(Storage *)> StorageUniquePointer
unique_ptr (with deleter) to Storage[]
Definition: SignalsCatcherControlBlock.hpp:44
SignalAction class contains information needed to handle signal that was caught.
Definition: SignalAction.hpp:30
SignalsCatcherControlBlock(StorageUniquePointer &&storageUniquePointer, size_t storageSize)
SignalsCatcherControlBlock&#39;s constructor.
Definition: SignalsCatcherControlBlock.cpp:178
void deliveryOfSignalsStartedHook()
Hook function executed when delivery of signals is started.
Definition: SignalsCatcherControlBlock.hpp:100
int beforeGenerateQueue(ThreadControlBlock &threadControlBlock)
Part of SignalsReceiverControlBlock::beforeGenerateQueue() specific to catching unmasked signals...
Definition: SignalsCatcherControlBlock.cpp:205
Storage * storageEnd_
pointer to "one past the last" element of range of Storage objects
Definition: SignalsCatcherControlBlock.hpp:224