RSC
0.12.1
|
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... | |
template<class R > | |
class | DEPRECATED_CLASS ("If possible, use rsc::patterns::Factory instead") Registry |
A templatized global registry. More... | |
DEPRECATED_MSG (void addRegistree(R *r, const std::string &errorDescription=""),"If possible, use rsc::patterns::Factory instead") | |
Registers a new registree in the Registry. More... | |
DEPRECATED_MSG (boost::shared_ptr< R > getRegistree(const std::string &key),"If possible, use rsc::patterns::Factory instead") | |
Returns the registree for the provided key. More... | |
DEPRECATED_MSG (std::set< std::string > getKnownRegistryKeys(),"If possible, use rsc::patterns::Factory instead") | |
Returns a set with all known registree keys. More... | |
DEPRECATED_MSG (bool removeRegistree(const std::string &name),"If possible, use rsc::patterns::Factory instead") | |
Removes a registree from this registry. More... | |
DEPRECATED_MSG (boost::recursive_mutex *getMutex(),"If possible, use rsc::patterns::Factory instead") | |
Returns a recursive mutex that can be used to make multiple operations on this class atomic. 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 |
boost::recursive_mutex | mutex |
std::map< std::string, boost::shared_ptr< R > > | registreesByName |
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().
class rsc::misc::DEPRECATED_CLASS | ( | "If | possible, |
use rsc::patterns::Factory instead" | |||
) |
A templatized global registry.
To create a registree, that will be registered on application startup before main use the provided macros. This will work on every supported compiler.
This class is reentrant.
R | type to register called registree. |
Definition at line 62 of file Registry.h.
rsc::misc::DEPRECATED_MSG | ( | void | addRegistreeR *r, const std::string &errorDescription="", |
"If | possible, | ||
use rsc::patterns::Factory instead" | |||
) |
Registers a new registree in the Registry.
This class takes over the ownership of the pointer and manages deleting the pointer when needed.
r | new registree to register |
errorDescription | optional string to add to the message of the exception which is raised when a registree with a same key already exists. |
std::invalid_argument | if a registree with the same key is already registered. In this case r is not owned by this registry |
Definition at line 80 of file Registry.h.
References mutex, and registreesByName.
rsc::misc::DEPRECATED_MSG | ( | boost::shared_ptr< R > | getRegistreeconst std::string &key, |
"If | possible, | ||
use rsc::patterns::Factory instead" | |||
) |
Returns the registree for the provided key.
key | key of the registree |
std::invalid_argument | if there is no registree with this name |
Definition at line 102 of file Registry.h.
References mutex, and registreesByName.
rsc::misc::DEPRECATED_MSG | ( | std::set< std::string > | getKnownRegistryKeys(), |
"If | possible, | ||
use rsc::patterns::Factory instead" | |||
) |
Returns a set with all known registree keys.
Definition at line 123 of file Registry.h.
References mutex, and registreesByName.
rsc::misc::DEPRECATED_MSG | ( | bool | removeRegistreeconst std::string &name, |
"If | possible, | ||
use rsc::patterns::Factory instead" | |||
) |
Removes a registree from this registry.
Use this with caution as many clients will assume that system configuration knowledge is static!
name | name of the registree to remove |
true
if a registree was removed, else false
Definition at line 145 of file Registry.h.
References mutex, and registreesByName.
rsc::misc::DEPRECATED_MSG | ( | boost::recursive_mutex * | getMutex(), |
"If | possible, | ||
use rsc::patterns::Factory instead" | |||
) |
Returns a recursive mutex that can be used to make multiple operations on this class atomic.
Definition at line 157 of file Registry.h.
References mutex.
void rsc::misc::handler | ( | int | signal | ) |
Definition at line 48 of file MacSignalWaiter.cpp.
References receivedSignal, and semaphore.
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(), requestedSignals, semaphore, semaphore_name, 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(), and requestedSignals.
Signal rsc::misc::mappedSignal | ( | ) |
Definition at line 109 of file MacSignalWaiter.cpp.
References INTERRUPT_REQUESTED, NO_SIGNAL, QUIT_REQUESTED, receivedSignal, 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(), receivedSignal, requestedSignals, semaphore, semaphore_name, and throwRuntimeError().
boost::recursive_mutex rsc::misc::mutex |
Definition at line 164 of file Registry.h.
Referenced by rsc::logging::TreeLevelUpdater::call(), rsc::logging::LoggerFactory::clearKnownLoggers(), rsc::logging::LoggerFactory::createLogger(), rsc::patterns::Singleton< T >::createMutex(), DEPRECATED_MSG(), rsc::patterns::Singleton< T >::getInstance(), rsc::patterns::Singleton< T >::getInstanceMutex(), rsc::logging::LoggerFactory::getLogger(), rsc::logging::LoggerFactory::getLoggingSystemName(), rsc::patterns::Singleton< T >::killInstance(), rsc::logging::LoggerFactory::LoggerFactory(), rsc::logging::LoggerFactory::reconfigure(), and rsc::logging::LoggerFactory::reselectLoggingSystem().
volatile sig_atomic_t rsc::misc::receivedSignal = 0 |
Definition at line 46 of file MacSignalWaiter.cpp.
Referenced by handler(), mappedSignal(), and waitForSignal().
std::map<std::string, boost::shared_ptr<R> > rsc::misc::registreesByName |
Definition at line 165 of file Registry.h.
Referenced by DEPRECATED_MSG().
int rsc::misc::requestedSignals = 0 |
Definition at line 43 of file MacSignalWaiter.cpp.
Referenced by initSignalWaiter(), lastArrivedSignal(), and waitForSignal().
sem_t rsc::misc::semaphore |
Definition at line 45 of file MacSignalWaiter.cpp.
Referenced by handler(), initSignalWaiter(), and waitForSignal().
|
static |
Definition at line 44 of file MacSignalWaiter.cpp.
Referenced by initSignalWaiter(), and waitForSignal().