distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
distortos::internal::SignalsReceiverControlBlock Class Reference

SignalsReceiverControlBlock class is a structure required by threads for "receiving" of signals. More...

#include "distortos/internal/synchronization/SignalsReceiverControlBlock.hpp"

Collaboration diagram for distortos::internal::SignalsReceiverControlBlock:
[legend]

Public Member Functions

 SignalsReceiverControlBlock (SignalInformationQueueWrapper *signalInformationQueueWrapper, SignalsCatcher *signalsCatcher)
 SignalsReceiverControlBlock's constructor. More...
 
std::pair< int, SignalInformationacceptPendingSignal (uint8_t signalNumber)
 Accepts (clears) one of signals that are pending. More...
 
int deliveryOfSignalsStartedHook () const
 Hook function executed when delivery of signals is started. More...
 
int generateSignal (uint8_t signalNumber, ThreadControlBlock &threadControlBlock)
 Generates signal for associated thread. More...
 
SignalSet getPendingSignalSet () const
 
std::pair< int, SignalActiongetSignalAction (uint8_t signalNumber) const
 Gets SignalAction associated with given signal number. More...
 
SignalSet getSignalMask () const
 Gets signal mask for associated thread. More...
 
int queueSignal (uint8_t signalNumber, sigval value, ThreadControlBlock &threadControlBlock) const
 Queues signal for associated thread. More...
 
std::pair< int, SignalActionsetSignalAction (uint8_t signalNumber, const SignalAction &signalAction)
 Sets association for given signal number. More...
 
int setSignalMask (SignalSet signalMask, bool deliver)
 Sets signal mask for associated thread. More...
 
void setWaitingSignalSet (const SignalSet *const signalSet)
 

Private Member Functions

void afterGenerateQueueLocked (uint8_t signalNumber, ThreadControlBlock &threadControlBlock) const
 Actions executed from within critical section after signal is generated with generateSignal() or queued with queueSignal(). More...
 
void afterGenerateQueueUnlocked (uint8_t signalNumber, ThreadControlBlock &threadControlBlock) const
 Actions executed out of critical section after signal is generated with generateSignal() or queued with queueSignal(). More...
 
int beforeGenerateQueue (uint8_t signalNumber, ThreadControlBlock &threadControlBlock) const
 Actions executed before signal is generated with generateSignal() or queued with queueSignal(). More...
 
std::pair< int, bool > isSignalIgnored (uint8_t signalNumber) const
 Checks whether signal is ignored. More...
 

Private Attributes

SignalSet pendingSignalSet_
 set of pending signals More...
 
const SignalSetwaitingSignalSet_
 pointer to set of "waited for" signals, nullptr if associated thread is not waiting for any signals More...
 
SignalsCatcherControlBlocksignalsCatcherControlBlock_
 pointer to SignalsCatcherControlBlock for this receiver, nullptr if this receiver cannot catch/handle signals More...
 
SignalInformationQueuesignalInformationQueue_
 pointer to SignalInformationQueue for this receiver, nullptr if this receiver cannot queue signals More...
 

Detailed Description

SignalsReceiverControlBlock class is a structure required by threads for "receiving" of signals.

Constructor & Destructor Documentation

◆ SignalsReceiverControlBlock()

distortos::internal::SignalsReceiverControlBlock::SignalsReceiverControlBlock ( SignalInformationQueueWrapper signalInformationQueueWrapper,
SignalsCatcher signalsCatcher 
)
explicit

SignalsReceiverControlBlock's constructor.

Parameters
[in]signalInformationQueueWrapperis a pointer to SignalInformationQueueWrapper for this receiver, nullptr to disable queuing of signals for this receiver
[in]signalsCatcheris a pointer to SignalsCatcher for this receiver, nullptr if this receiver cannot catch/handle signals

Member Function Documentation

◆ acceptPendingSignal()

std::pair< int, SignalInformation > distortos::internal::SignalsReceiverControlBlock::acceptPendingSignal ( uint8_t  signalNumber)

Accepts (clears) one of signals that are pending.

This should be called when the signal is "accepted".

Parameters
[in]signalNumberis the signal that will be accepted, [0; 31]
Returns
pair with return code (0 on success, error code otherwise) and SignalInformation object for accepted signal; error codes:
Here is the call graph for this function:
Here is the caller graph for this function:

◆ afterGenerateQueueLocked()

void distortos::internal::SignalsReceiverControlBlock::afterGenerateQueueLocked ( uint8_t  signalNumber,
ThreadControlBlock threadControlBlock 
) const
private

Actions executed from within critical section after signal is generated with generateSignal() or queued with queueSignal().

Does nothing if the signal is not masked. Otherwise unblocks associated thread if it is currently waiting for the signal that was generated/queued.

Parameters
[in]signalNumberis the signal that was generated/queued, [0; 31]
[in]threadControlBlockis a reference to associated ThreadControlBlock
Here is the call graph for this function:
Here is the caller graph for this function:

◆ afterGenerateQueueUnlocked()

void distortos::internal::SignalsReceiverControlBlock::afterGenerateQueueUnlocked ( uint8_t  signalNumber,
ThreadControlBlock threadControlBlock 
) const
private

Actions executed out of critical section after signal is generated with generateSignal() or queued with queueSignal().

Parameters
[in]signalNumberis the signal that was generated/queued, [0; 31]
[in]threadControlBlockis a reference to associated ThreadControlBlock
Here is the call graph for this function:
Here is the caller graph for this function:

◆ beforeGenerateQueue()

int distortos::internal::SignalsReceiverControlBlock::beforeGenerateQueue ( uint8_t  signalNumber,
ThreadControlBlock threadControlBlock 
) const
private

Actions executed before signal is generated with generateSignal() or queued with queueSignal().

Requests delivery it the generated/queued signal is not masked.

Parameters
[in]signalNumberis the signal that will be generated/queued, [0; 31]
[in]threadControlBlockis a reference to associated ThreadControlBlock
Returns
0 on success, error code otherwise:
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deliveryOfSignalsStartedHook()

int distortos::internal::SignalsReceiverControlBlock::deliveryOfSignalsStartedHook ( ) const

Hook function executed when delivery of signals is started.

Calls SignalsCatcherControlBlock::deliveryOfSignalsStartedHook().

Attention
This function should be called only by the function that delivers signals (deliverSignals()).
Returns
0 on success, error code otherwise:
  • ENOTSUP - catching/handling of signals is disabled for this receiver;
Here is the call graph for this function:

◆ generateSignal()

int distortos::internal::SignalsReceiverControlBlock::generateSignal ( uint8_t  signalNumber,
ThreadControlBlock threadControlBlock 
)

Generates signal for associated thread.

Similar to pthread_kill() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_kill.html

Adds the signalNumber to set of pending signals. If associated thread is currently waiting for this signal, it will be unblocked.

Parameters
[in]signalNumberis the signal that will be generated, [0; 31]
[in]threadControlBlockis a reference to associated ThreadControlBlock
Returns
0 on success, error code otherwise:
Here is the call graph for this function:

◆ getPendingSignalSet()

SignalSet distortos::internal::SignalsReceiverControlBlock::getPendingSignalSet ( ) const
Returns
set of currently pending signals
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSignalAction()

std::pair< int, SignalAction > distortos::internal::SignalsReceiverControlBlock::getSignalAction ( uint8_t  signalNumber) const

Gets SignalAction associated with given signal number.

Similar to sigaction() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaction.html

Parameters
[in]signalNumberis the signal for which the association is requested, [0; 31]
Returns
pair with return code (0 on success, error code otherwise) and SignalAction that is associated with signalNumber, default-constructed object if no association was found; error codes:
Here is the call graph for this function:

◆ getSignalMask()

SignalSet distortos::internal::SignalsReceiverControlBlock::getSignalMask ( ) const

Gets signal mask for associated thread.

Similar to pthread_sigmask() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html#

Returns
SignalSet with signal mask for associated thread
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSignalIgnored()

std::pair< int, bool > distortos::internal::SignalsReceiverControlBlock::isSignalIgnored ( uint8_t  signalNumber) const
private

Checks whether signal is ignored.

Signal is ignored if it has no SignalAction object associated. Signal is never ignored if catching/handling of signals is disabled for this receiver.

Parameters
[in]signalNumberis the signal for which the check will be performed, [0; 31]
Returns
pair with return code (0 on success, error code otherwise) and boolean telling whether the signal is ignored (true) or not (false); error codes:
  • EINVAL - signalNumber value is invalid;
Here is the call graph for this function:
Here is the caller graph for this function:

◆ queueSignal()

int distortos::internal::SignalsReceiverControlBlock::queueSignal ( uint8_t  signalNumber,
sigval  value,
ThreadControlBlock threadControlBlock 
) const

Queues signal for associated thread.

Similar to sigqueue() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigqueue.html

Queues the signalNumber and signal value (sigval union) in associated SignalInformationQueue object. If associated thread is currently waiting for this signal, it will be unblocked.

Parameters
[in]signalNumberis the signal that will be queued, [0; 31]
[in]valueis the signal value
[in]threadControlBlockis a reference to associated ThreadControlBlock
Returns
0 on success, error code otherwise:
Here is the call graph for this function:

◆ setSignalAction()

std::pair< int, SignalAction > distortos::internal::SignalsReceiverControlBlock::setSignalAction ( uint8_t  signalNumber,
const SignalAction signalAction 
)

Sets association for given signal number.

Similar to sigaction() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaction.html

Parameters
[in]signalNumberis the signal for which the association will be set, [0; 31]
[in]signalActionis a reference to SignalAction that will be associated with given signal number, object in internal storage is copy-constructed
Returns
pair with return code (0 on success, error code otherwise) and SignalAction that was associated with signalNumber, default-constructed object if no association was found; error codes:
Here is the call graph for this function:

◆ setSignalMask()

int distortos::internal::SignalsReceiverControlBlock::setSignalMask ( SignalSet  signalMask,
bool  deliver 
)

Sets signal mask for associated thread.

Similar to pthread_sigmask() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html#

Parameters
[in]signalMaskis the SignalSet with new signal mask for associated thread
[in]deliverselects whether pending and unblocked signals will be delivered (true) or not (false)
Returns
0 on success, error code otherwise:
  • ENOTSUP - catching/handling of signals is disabled for this receiver;
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setWaitingSignalSet()

void distortos::internal::SignalsReceiverControlBlock::setWaitingSignalSet ( const SignalSet *const  signalSet)
inline
Parameters
[in]signalSetis a pointer to set of signals that will be "waited for", nullptr when wait was terminated
Here is the caller graph for this function:

Member Data Documentation

◆ pendingSignalSet_

SignalSet distortos::internal::SignalsReceiverControlBlock::pendingSignalSet_
private

set of pending signals

◆ signalInformationQueue_

SignalInformationQueue* distortos::internal::SignalsReceiverControlBlock::signalInformationQueue_
private

pointer to SignalInformationQueue for this receiver, nullptr if this receiver cannot queue signals

◆ signalsCatcherControlBlock_

SignalsCatcherControlBlock* distortos::internal::SignalsReceiverControlBlock::signalsCatcherControlBlock_
private

pointer to SignalsCatcherControlBlock for this receiver, nullptr if this receiver cannot catch/handle signals

◆ waitingSignalSet_

const SignalSet* distortos::internal::SignalsReceiverControlBlock::waitingSignalSet_
private

pointer to set of "waited for" signals, nullptr if associated thread is not waiting for any signals


The documentation for this class was generated from the following files: