Kea  1.5.0
isc::process::IOSignalQueue Class Reference

Creates and manages IOSignals. More...

#include <io_service_signal.h>

Public Member Functions

 IOSignalQueue (asiolink::IOServicePtr &io_service)
 Constructor. More...
 
 ~IOSignalQueue ()
 Destructor. More...
 
void clear ()
 Erases the contents of the queue. More...
 
IOSignalPtr popSignal (IOSignalId sequence_id)
 Removes an IOSignal from the map and returns it. More...
 
IOSignalId pushSignal (int signum, IOSignalHandler handler)
 Creates an IOSignal. More...
 

Detailed Description

Creates and manages IOSignals.

This class is used to create IOSignals, house them until they are delivered, and dequeue them so they can be been handled. IOSignals are designed to used once and then destroyed. They need to be created from within OS signal handlers and persist until they have been delivered and processed.

This class is designed specifically to make managing them painless. It maintains an internal map of IOSignals keyed by sequence_id. When a signal is created via the pushSignal() method it is added to the map. When a signal is retrieved via the popSignal() method it is removed from the map.

Definition at line 194 of file io_service_signal.h.

Constructor & Destructor Documentation

◆ IOSignalQueue()

isc::process::IOSignalQueue::IOSignalQueue ( asiolink::IOServicePtr io_service)

Constructor.

Parameters
io_servicethe IOService to which to send signals.
Exceptions
IOSignalErrorif io_service is NULL.

Definition at line 62 of file io_service_signal.cc.

References isc_throw.

◆ ~IOSignalQueue()

isc::process::IOSignalQueue::~IOSignalQueue ( )

Destructor.

Definition at line 69 of file io_service_signal.cc.

References clear().

+ Here is the call graph for this function:

Member Function Documentation

◆ clear()

void isc::process::IOSignalQueue::clear ( )

Erases the contents of the queue.

Any instances still in the map will be destroyed. This will cause their timers to be cancelled without any callbacks invoked. (Not sure when this might be desirable).

Definition at line 113 of file io_service_signal.cc.

Referenced by ~IOSignalQueue().

◆ popSignal()

IOSignalPtr isc::process::IOSignalQueue::popSignal ( IOSignalId  sequence_id)

Removes an IOSignal from the map and returns it.

Given a sequence_id this method will extract the IOSignal from the internal map and return. At that point, the caller will hold the only copy of the IOSignal.

Parameters
sequence_idsequence_id of the IOSignal to retrieve.
Returns
A smart pointer to the IOSignal.
Exceptions
IOSignalErrorif there is no matching IOSignal in the map for the given sequence_id. Other than by doubling popping, this should be very unlikely.

Definition at line 93 of file io_service_signal.cc.

References isc_throw.

◆ pushSignal()

IOSignalId isc::process::IOSignalQueue::pushSignal ( int  signum,
IOSignalHandler  handler 
)

Creates an IOSignal.

Given a signal number and a handler, it will instantiate an IOSignal and add it to the instance map. (Remember that IOSignals are really just timers programmed during construction, so once instantiated there's nothing more required to "send" the signal other than return control to IOService::run()).

Parameters
signumOS signal value of the signal to propagate
handlerIOSignalHandler to invoke when the signal is delivered.
Returns
The sequence_id of the newly created signal.
Exceptions
IOSignalErrorif the sequence_id already exists in the map. This is virtually impossible unless things have gone very wrong.

Definition at line 74 of file io_service_signal.cc.

References isc_throw.


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