feisty meow concerns codebase
2.140
|
An inter-process synchronization primitive. More...
#include <rendezvous.h>
Public Types | |
enum | locking_methods { NO_LOCKING , ENDLESS_WAIT , IMMEDIATE_RETURN } |
different ways that the lock() attempt can be made. More... | |
Public Member Functions | |
rendezvous (const basis::astring &root_name) | |
the healthy() method should be checked to ensure creation succeeded. More... | |
virtual | ~rendezvous () |
any lock held is released and the lower level structures freed. More... | |
DEFINE_CLASS_NAME ("rendezvous") | |
bool | healthy () const |
returns true if the rendezvous object is operable. More... | |
bool | lock (locking_methods how=ENDLESS_WAIT) |
grab the lock, if possible. More... | |
void | unlock () |
releases a previously acquired lock. More... | |
virtual void | establish_lock () |
virtual void | repeal_lock () |
const basis::astring & | root_name () const |
returns the root name passed in the constructor. More... | |
An inter-process synchronization primitive.
A lock can be created that only one process owns at a time; those that do not acquire the lock can either return immediately or wait until the current lock owner releases the rendezvous. This is unlike the mutex object in basis, since mutexes only synchronize within the same application. The rendezvous can instead allow synchronization of resources between applications, but this comes at a higher cost per usage.
Definition at line 33 of file rendezvous.h.
different ways that the lock() attempt can be made.
Enumerator | |
---|---|
NO_LOCKING | |
ENDLESS_WAIT | |
IMMEDIATE_RETURN |
Definition at line 50 of file rendezvous.h.
processes::rendezvous::rendezvous | ( | const basis::astring & | root_name | ) |
the healthy() method should be checked to ensure creation succeeded.
Definition at line 70 of file rendezvous.cpp.
References FUNCDEF, processes::general_lock_name(), LOG, NULL_POINTER, root_name(), basis::astring::s(), and processes::unix_rendez_file().
|
virtual |
any lock held is released and the lower level structures freed.
Definition at line 98 of file rendezvous.cpp.
References fileno, FUNCDEF, LOG, NULL_POINTER, and basis::WHACK().
processes::rendezvous::DEFINE_CLASS_NAME | ( | "rendezvous" | ) |
|
virtual |
Implements basis::base_synchronizer.
Definition at line 132 of file rendezvous.cpp.
References lock().
bool processes::rendezvous::healthy | ( | ) | const |
returns true if the rendezvous object is operable.
there are cases where creation of the rendezvous might fail; they can be trapped here.
Definition at line 136 of file rendezvous.cpp.
bool processes::rendezvous::lock | ( | locking_methods | how = ENDLESS_WAIT | ) |
grab the lock, if possible.
if this is not the first time locking the same rendezvous, that's fine as long as the number of unlocks matches the number of locks.
Definition at line 141 of file rendezvous.cpp.
References ENDLESS_WAIT, fileno, FUNCDEF, healthy(), LOG, and NO_LOCKING.
Referenced by application::singleton_application::allow_this_instance(), establish_lock(), application::shared_memory::lock(), and application::shared_memory::shared_memory().
|
virtual |
Implements basis::base_synchronizer.
Definition at line 134 of file rendezvous.cpp.
References unlock().
const basis::astring& processes::rendezvous::root_name | ( | ) | const |
returns the root name passed in the constructor.
Referenced by rendezvous().
void processes::rendezvous::unlock | ( | ) |
releases a previously acquired lock.
Definition at line 181 of file rendezvous.cpp.
References fileno, FUNCDEF, healthy(), and LOG.
Referenced by application::singleton_application::release_lock(), repeal_lock(), application::shared_memory::shared_memory(), and application::shared_memory::unlock().