feisty meow concerns codebase  2.140
application::singleton_application Class Reference

#include <singleton_application.h>

Public Member Functions

 singleton_application (const basis::astring &application_name, const basis::astring &user_name=basis::astring::empty_string())
 constructs a singleton guardian for the "application_name". More...
 
virtual ~singleton_application ()
 
 DEFINE_CLASS_NAME ("singleton_application")
 
bool already_tried () const
 returns true if the singleton has already tried to lock. More...
 
bool allow_this_instance ()
 the application must check this before starting up. More...
 
bool already_running ()
 returns false if this program is not already running. More...
 
void release_lock ()
 let's go of the application lock, if we had previously gotten it. More...
 

Detailed Description

Definition at line 32 of file singleton_application.h.

Constructor & Destructor Documentation

◆ singleton_application()

application::singleton_application::singleton_application ( const basis::astring application_name,
const basis::astring user_name = basis::astring::empty_string() 
)

constructs a singleton guardian for the "application_name".

if the "user_name" is non-empty, then it will be used as part of the lock name. this ensures that separate users can still run the application at the same time, which is especially important for terminal servers. for a lock that should affect the whole machine and ignore users, the "user_name" must be empty.

Definition at line 26 of file singleton_application.cpp.

◆ ~singleton_application()

application::singleton_application::~singleton_application ( )
virtual

Definition at line 35 of file singleton_application.cpp.

References release_lock(), and basis::WHACK().

Member Function Documentation

◆ allow_this_instance()

bool application::singleton_application::allow_this_instance ( )

the application must check this before starting up.

if this returns false, then the application must exit immediately or it will be violating the singleton rule.

Definition at line 55 of file singleton_application.cpp.

References already_tried(), and processes::rendezvous::lock().

Referenced by already_running().

◆ already_running()

bool application::singleton_application::already_running ( )

returns false if this program is not already running.

this is just the opposite of the allow_this_instance() method.

Definition at line 41 of file singleton_application.cpp.

References allow_this_instance().

◆ already_tried()

bool application::singleton_application::already_tried ( ) const

returns true if the singleton has already tried to lock.

Definition at line 44 of file singleton_application.cpp.

Referenced by allow_this_instance().

◆ DEFINE_CLASS_NAME()

application::singleton_application::DEFINE_CLASS_NAME ( "singleton_application"  )

◆ release_lock()

void application::singleton_application::release_lock ( )

let's go of the application lock, if we had previously gotten it.

this should only be called when the application is about to exit.

Definition at line 47 of file singleton_application.cpp.

References processes::rendezvous::unlock().

Referenced by ~singleton_application().


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