distortos  v0.4.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 #include <memory>
18 
19 namespace distortos
20 {
21 
22 namespace internal
23 {
24 
25 class SignalsReceiverControlBlock;
26 class ThreadControlBlock;
27 
30 {
31 public:
32 
34  using Association = std::pair<SignalSet, SignalAction>;
35 
37  using Storage = std::aligned_storage<sizeof(Association), alignof(Association)>::type;
38 
40  using StorageUniquePointer = std::unique_ptr<Storage[], void(&)(Storage*)>;
41 
50  SignalsCatcherControlBlock(StorageUniquePointer&& storageUniquePointer, size_t storageSize);
51 
57 
67  {
68  deliveryIsPending_ = false;
69  }
70 
81  std::pair<int, SignalAction> getAssociation(uint8_t signalNumber) const;
82 
88  {
89  return signalMask_;
90  }
91 
105  int postGenerate(uint8_t signalNumber, ThreadControlBlock& threadControlBlock);
106 
120  std::pair<int, SignalAction> setAssociation(uint8_t signalNumber, const SignalAction& signalAction);
121 
136  int setSignalMask(SignalSet signalMask, const SignalsReceiverControlBlock* owner);
137 
140  const SignalsCatcherControlBlock& operator=(const SignalsCatcherControlBlock&) = delete;
142 
143 private:
144 
154  SignalAction clearAssociation(uint8_t signalNumber);
155 
166  SignalAction clearAssociation(uint8_t signalNumber, Association& association);
167 
173  {
174  return reinterpret_cast<Association*>(storageUniquePointer_.get());
175  }
176 
189  int requestDeliveryOfSignals(ThreadControlBlock& threadControlBlock);
190 
193 
196 
198  union
199  {
202 
205  };
206 
209 
212 };
213 
214 } // namespace internal
215 
216 } // namespace distortos
217 
218 #endif // INCLUDE_DISTORTOS_INTERNAL_SYNCHRONIZATION_SIGNALSCATCHERCONTROLBLOCK_HPP_
SignalSet signalMask_
SignalSet with signal mask for associated thread.
Definition: SignalsCatcherControlBlock.hpp:195
Association * associationsEnd_
pointer to "one past the last" element of range of Association objects
Definition: SignalsCatcherControlBlock.hpp:201
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:37
SignalAction clearAssociation(uint8_t signalNumber)
Clears association for given signal number.
Definition: SignalsCatcherControlBlock.cpp:282
SignalsCatcherControlBlock class is a structure required by threads for "catching" and "handling" of ...
Definition: SignalsCatcherControlBlock.hpp:29
std::pair< SignalSet, SignalAction > Association
association of signal numbers (as SignalSet) with SignalAction
Definition: SignalsCatcherControlBlock.hpp:34
SignalsReceiverControlBlock class is a structure required by threads for "receiving" of signals...
Definition: SignalsReceiverControlBlock.hpp:37
Association * getAssociationsBegin() const
Definition: SignalsCatcherControlBlock.hpp:172
SignalAction class header.
int requestDeliveryOfSignals(ThreadControlBlock &threadControlBlock)
Requests delivery of signals to associated thread.
Definition: SignalsCatcherControlBlock.cpp:309
std::pair< int, SignalAction > getAssociation(uint8_t signalNumber) const
Gets SignalAction associated with given signal number.
Definition: SignalsCatcherControlBlock.cpp:191
SignalSet getSignalMask() const
Definition: SignalsCatcherControlBlock.hpp:87
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:186
bool deliveryIsPending_
true if signal delivery is pending, false otherwise
Definition: SignalsCatcherControlBlock.hpp:211
Storage * storageBegin_
pointer to first element of range of Storage objects
Definition: SignalsCatcherControlBlock.hpp:204
int setSignalMask(SignalSet signalMask, const SignalsReceiverControlBlock *owner)
Sets signal mask for associated thread.
Definition: SignalsCatcherControlBlock.cpp:261
std::pair< int, SignalAction > setAssociation(uint8_t signalNumber, const SignalAction &signalAction)
Sets association for given signal number.
Definition: SignalsCatcherControlBlock.cpp:214
StorageUniquePointer storageUniquePointer_
storage for Association objects
Definition: SignalsCatcherControlBlock.hpp:192
std::unique_ptr< Storage[], void(&)(Storage *)> StorageUniquePointer
unique_ptr (with deleter) to Storage[]
Definition: SignalsCatcherControlBlock.hpp:40
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:175
void deliveryOfSignalsStartedHook()
Hook function executed when delivery of signals is started.
Definition: SignalsCatcherControlBlock.hpp:66
int postGenerate(uint8_t signalNumber, ThreadControlBlock &threadControlBlock)
Part of SignalsReceiverControlBlock::postGenerate() specific to catching unmasked signals...
Definition: SignalsCatcherControlBlock.cpp:203
Storage * storageEnd_
pointer to "one past the last" element of range of Storage objects
Definition: SignalsCatcherControlBlock.hpp:208