distortos  v0.4.0
object-oriented C++ RTOS for microcontrollers
ThisThread-Signals.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_THISTHREAD_SIGNALS_HPP_
13 #define INCLUDE_DISTORTOS_THISTHREAD_SIGNALS_HPP_
14 
16 #include "distortos/TickClock.hpp"
17 
18 #include <utility>
19 
20 #include <cstdint>
21 
22 namespace distortos
23 {
24 
25 class SignalAction;
26 class SignalSet;
27 
28 namespace ThisThread
29 {
30 
31 namespace Signals
32 {
33 
36 
52 int generateSignal(uint8_t signalNumber);
53 
66 SignalSet getPendingSignalSet();
67 
83 std::pair<int, SignalAction> getSignalAction(uint8_t signalNumber);
84 
95 SignalSet getSignalMask();
96 
113 int queueSignal(uint8_t signalNumber, sigval value);
114 
132 std::pair<int, SignalAction> setSignalAction(uint8_t signalNumber, const SignalAction& signalAction);
133 
148 int setSignalMask(SignalSet signalMask);
149 
168 std::pair<int, SignalInformation> tryWait(const SignalSet& signalSet);
169 
189 std::pair<int, SignalInformation> tryWaitFor(const SignalSet& signalSet, TickClock::duration duration);
190 
209 template<typename Rep, typename Period>
210 std::pair<int, SignalInformation> tryWaitFor(const SignalSet& signalSet,
211  const std::chrono::duration<Rep, Period> duration)
212 {
213  return tryWaitFor(signalSet, std::chrono::duration_cast<TickClock::duration>(duration));
214 }
215 
235 std::pair<int, SignalInformation> tryWaitUntil(const SignalSet& signalSet, TickClock::time_point timePoint);
236 
254 template<typename Duration>
255 std::pair<int, SignalInformation> tryWaitUntil(const SignalSet& signalSet,
256  const std::chrono::time_point<TickClock, Duration> timePoint)
257 {
258  return tryWaitUntil(signalSet, std::chrono::time_point_cast<TickClock::duration>(timePoint));
259 }
260 
279 std::pair<int, SignalInformation> wait(const SignalSet& signalSet);
280 
282 
283 } // namespace Signals
284 
285 } // namespace ThisThread
286 
287 } // namespace distortos
288 
289 #endif // INCLUDE_DISTORTOS_THISTHREAD_SIGNALS_HPP_
Definition: signal.h:28
SignalSet getSignalMask()
Gets signal mask for current thread.
Definition: ThisThread-Signals.cpp:168
std::pair< int, SignalAction > getSignalAction(uint8_t signalNumber)
Gets SignalAction associated with given signal number.
Definition: ThisThread-Signals.cpp:155
std::pair< int, SignalInformation > tryWaitUntil(const SignalSet &signalSet, TickClock::time_point timePoint)
Tries to wait for signals until given time point.
Definition: ThisThread-Signals.cpp:220
int setSignalMask(SignalSet signalMask)
Sets signal mask for current thread.
Definition: ThisThread-Signals.cpp:198
SignalSet getPendingSignalSet()
Gets set of currently pending signals for current thread.
Definition: ThisThread-Signals.cpp:150
std::chrono::time_point< TickClock > time_point
basic time_point type of clock
Definition: TickClock.hpp:42
std::pair< int, SignalAction > setSignalAction(uint8_t signalNumber, const SignalAction &signalAction)
Sets association for given signal number.
Definition: ThisThread-Signals.cpp:185
TickClock class header.
SignalSet class is used as a set of signals.
Definition: SignalSet.hpp:28
std::pair< int, SignalInformation > tryWaitFor(const SignalSet &signalSet, TickClock::duration duration)
Tries to wait for signals for given duration of time.
Definition: ThisThread-Signals.cpp:215
Top-level namespace of distortos project.
std::pair< int, SignalInformation > tryWait(const SignalSet &signalSet)
Tries to accept pending signals.
Definition: ThisThread-Signals.cpp:210
std::chrono::duration< rep, period > duration
basic duration type of clock
Definition: TickClock.hpp:39
SignalInformation class header.
int generateSignal(uint8_t signalNumber)
Generates signal for current thread.
Definition: ThisThread-Signals.cpp:145
int queueSignal(uint8_t signalNumber, sigval value)
Queues signal for current thread.
Definition: ThisThread-Signals.cpp:180
std::pair< int, SignalInformation > wait(const SignalSet &signalSet)
Waits for signals.
Definition: ThisThread-Signals.cpp:225