BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Public Types | Public Member Functions
BeeeOn::SingleInstanceChecker Class Reference

SingleInstanceChecker can detect another equivalent running application instance. This might prevent running a same kind of application multiple-times. More...

#include <SingleInstanceChecker.h>

Inheritance diagram for BeeeOn::SingleInstanceChecker:
BeeeOn::Loggable

Public Types

enum  Mode { MODE_FAIL, MODE_IGNORE, MODE_RECOVER }
 

Public Member Functions

void setName (const std::string &name)
 
void setMode (const std::string &mode)
 
void check ()
 Try lock the global mutex. If it successfully locks, jsut continue. Otherwise, based on the configured mode, react on the situation by failing, ignoring or recovering.
 

Additional Inherited Members

- Protected Member Functions inherited from BeeeOn::Loggable
void setupLogger (Poco::Logger *logger=0) const
 
Poco::Logger & logger () const
 
 Loggable (const ClassInfo &info)
 
 Loggable (const std::type_info &info)
 
- Static Protected Member Functions inherited from BeeeOn::Loggable
static Poco::Logger & forMethod (const char *name)
 
static Poco::Logger & forClass (const ClassInfo &info)
 
static Poco::Logger & forClass (const std::type_info &info)
 
template<typename T >
static Poco::Logger & forInstance (const T *i)
 
static void configureSimple (Poco::Logger &logger, const std::string &level)
 
static void logException (Poco::Logger &logger, const Poco::Message::Priority priority, const Poco::Exception &e, const char *file, size_t line)
 

Detailed Description

SingleInstanceChecker can detect another equivalent running application instance. This might prevent running a same kind of application multiple-times.

SingleInstanceChecker uses Poco::NamedMutex internally to detect another running application instance having the same name. It tries to lock when the SingleInstanceChecker::check() is called and unlocks upon destruction.

There are 3 modes of operation with respect to the situation when another application instance is detected:

Member Enumeration Documentation

Enumerator
MODE_FAIL 

fail if another instance is detected

MODE_IGNORE 

ignore when another instance is detected

MODE_RECOVER 

recover from a false positive failure


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