RSC
0.16.0
|
Namespaces | |
detail | |
Classes | |
class | IllegalStateException |
Exception indicating a call on a method where the underlying object is in an illegal state for this call. More... | |
class | NullDeleter |
A deleter object that can be used with boost::shared_ptr that doesn't release any memory. More... | |
class | ParentSharedPtrDeleter |
A deleter for boost::shared_ptr which enables to use a pointer in a shared_ptr, which is not a shared_ptr itself and owned by another object. More... | |
class | UnsupportedOperationException |
An exception which indicates that a certain operation is not supported by the target. More... | |
class | UUID |
Encapsulates the generation and handling of UUIDs. More... | |
Typedefs | |
typedef boost::shared_ptr< UUID > | UUIDPtr |
Enumerations | |
enum | Signal { NO_SIGNAL = 0, INTERRUPT_REQUESTED = 0x01, TERMINATE_REQUESTED = 0x02, QUIT_REQUESTED = 0x04 } |
Signals waitForSignal can wait for. More... | |
Functions | |
boost::uint64_t | currentTimeMillis () |
Returns the current system time as milliseconds. More... | |
boost::uint64_t | currentTimeMicros () |
Returns the current system time as microseconds. More... | |
char | randAlnumChar () |
Generates a random alpha-numeric character. More... | |
std::string | randAlnumStr (const std::string::size_type &length) |
Generates a random alpha-numeric string with fixed length. More... | |
void | handler (int signal) |
void | throwRuntimeError (int errorNumber, const std::string &description) |
void | initSignalWaiter (int signals=INTERRUPT_REQUESTED|TERMINATE_REQUESTED) |
Prepare waiting for signals. More... | |
Signal | mappedSignal () |
Signal | waitForSignal () |
Block until one of the signals specified in initSignalWaiter arrives, then return the signal. More... | |
Signal | lastArrivedSignal () |
Returns the last signal that has arrived at this process or Signal::NO_SIGNAL in case no signal arrived so far. More... | |
int | suggestedExitCode (Signal signal) |
Return suggested exit code for exiting the program after receiving signal signal. More... | |
ostream & | operator<< (ostream &stream, const UUID &id) |
Variables | |
int | requestedSignals = 0 |
static std::string | semaphore_name |
sem_t * | semaphore |
volatile sig_atomic_t | receivedSignal = 0 |
typedef boost::shared_ptr<UUID> rsc::misc::UUIDPtr |
enum rsc::misc::Signal |
Signals waitForSignal can wait for.
The numeric values are chosen in a way that allows combining values via logical "or".
Definition at line 44 of file SignalWaiter.h.
RSC_EXPORT boost::uint64_t rsc::misc::currentTimeMicros | ( | ) |
Returns the current system time as microseconds.
Definition at line 82 of file langutils.cpp.
Referenced by rsc::threading::PeriodicTask::continueExec(), and initSignalWaiter().
RSC_EXPORT boost::uint64_t rsc::misc::currentTimeMillis | ( | ) |
Returns the current system time as milliseconds.
Definition at line 64 of file langutils.cpp.
Referenced by rsc::logging::ConsoleLogger::printHeader().
void rsc::misc::handler | ( | int | signal | ) |
Definition at line 48 of file MacSignalWaiter.cpp.
Referenced by initSignalWaiter().
void rsc::misc::initSignalWaiter | ( | int | signals = INTERRUPT_REQUESTED | TERMINATE_REQUESTED | ) |
Prepare waiting for signals.
The actual waiting is performed by waitForSignal.
This function be called at any time before waitForSignal, for example calling it at the very beginning of the program is fine. If such a program receives a signal early (i.e. before the waitForSignal call), the program will continue execution until waitForSignal is called and immediately continue there, for example by shutting down.
signals | The non-empty set of signals to wait for. Should be constructed by applying bitwise-or to elements of the Signal enumeration. |
std::runtime_error | If initialization fails, for example due to unavailable resources. |
std::program_error | If signals is 0, corresponding to the empty set of signals. |
Definition at line 63 of file MacSignalWaiter.cpp.
References currentTimeMicros(), handler(), INTERRUPT_REQUESTED, QUIT_REQUESTED, randAlnumStr(), TERMINATE_REQUESTED, and throwRuntimeError().
Signal rsc::misc::lastArrivedSignal | ( | ) |
Returns the last signal that has arrived at this process or Signal::NO_SIGNAL in case no signal arrived so far.
std::logic_error | If initSignalWaiter has not been called. |
Definition at line 159 of file MacSignalWaiter.cpp.
References mappedSignal().
Signal rsc::misc::mappedSignal | ( | ) |
Definition at line 109 of file MacSignalWaiter.cpp.
References INTERRUPT_REQUESTED, NO_SIGNAL, QUIT_REQUESTED, and TERMINATE_REQUESTED.
Referenced by lastArrivedSignal(), and waitForSignal().
RSC_EXPORT std::ostream & rsc::misc::operator<< | ( | ostream & | stream, |
const UUID & | id | ||
) |
RSC_EXPORT char rsc::misc::randAlnumChar | ( | ) |
Generates a random alpha-numeric character.
Definition at line 100 of file langutils.cpp.
Referenced by randAlnumStr().
RSC_EXPORT std::string rsc::misc::randAlnumStr | ( | const std::string::size_type & | length | ) |
Generates a random alpha-numeric string with fixed length.
length | desired length of the string |
Definition at line 108 of file langutils.cpp.
References randAlnumChar().
Referenced by initSignalWaiter().
int rsc::misc::suggestedExitCode | ( | Signal | signal | ) |
Return suggested exit code for exiting the program after receiving signal signal.
signal | The received signal as a member of the Signal enumeration. Signal::NO_SIGNAL is not allowed. |
Definition at line 168 of file MacSignalWaiter.cpp.
References INTERRUPT_REQUESTED, NO_SIGNAL, QUIT_REQUESTED, and TERMINATE_REQUESTED.
void rsc::misc::throwRuntimeError | ( | int | errorNumber, |
const std::string & | description | ||
) |
Definition at line 56 of file MacSignalWaiter.cpp.
Referenced by initSignalWaiter(), and waitForSignal().
Signal rsc::misc::waitForSignal | ( | ) |
Block until one of the signals specified in initSignalWaiter arrives, then return the signal.
std::logic_error | If initSignalWaiter has not been called. |
std::runtime_error | If waiting for signals fails. |
Definition at line 128 of file MacSignalWaiter.cpp.
References mappedSignal(), and throwRuntimeError().
volatile sig_atomic_t rsc::misc::receivedSignal = 0 |
Definition at line 46 of file MacSignalWaiter.cpp.
int rsc::misc::requestedSignals = 0 |
Definition at line 43 of file MacSignalWaiter.cpp.
sem_t rsc::misc::semaphore |
Definition at line 45 of file MacSignalWaiter.cpp.
|
static |
Definition at line 44 of file MacSignalWaiter.cpp.