![]() |
Kea
1.5.0
|
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... | |
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.
| isc::process::IOSignalQueue::IOSignalQueue | ( | asiolink::IOServicePtr & | io_service | ) |
Constructor.
| io_service | the IOService to which to send signals. |
| IOSignalError | if io_service is NULL. |
Definition at line 62 of file io_service_signal.cc.
References isc_throw.
| 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:| 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().
| 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.
| sequence_id | sequence_id of the IOSignal to retrieve. |
| IOSignalError | if 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.
| 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()).
| signum | OS signal value of the signal to propagate |
| handler | IOSignalHandler to invoke when the signal is delivered. |
| IOSignalError | if 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.