GNU CommonC++
Public Member Functions | List of all members
ost::Lockfile Class Reference

This class is used to create a "named" lock entity that can be used to control access to a resource between multiple processes. More...

#include <process.h>

Public Member Functions

 Lockfile (const char *name)
 Create a lock under a known name. More...
 
 Lockfile ()
 Create a new lock object that can be used to make locks. More...
 
 ~Lockfile ()
 Destroy the current lock and release it. More...
 
bool lock (const char *name)
 Lock a system-wide name for this process. More...
 
void unlock (void)
 Release an acquired lock. More...
 
bool isLocked (void)
 Flag if the current process has aqcuired a lock. More...
 

Detailed Description

This class is used to create a "named" lock entity that can be used to control access to a resource between multiple processes.

The posix implimentation uses a pidfile and the win32 version uses a globally visible mutex.

Author
David Sugar dyfet.nosp@m.@ost.nosp@m.el.co.nosp@m.m

System-wide named lock

Constructor & Destructor Documentation

◆ Lockfile() [1/2]

ost::Lockfile::Lockfile ( const char *  name)

Create a lock under a known name.

Parameters
nameof system-wide lock to create.

◆ Lockfile() [2/2]

ost::Lockfile::Lockfile ( )

Create a new lock object that can be used to make locks.

◆ ~Lockfile()

ost::Lockfile::~Lockfile ( )
inline

Destroy the current lock and release it.

Member Function Documentation

◆ isLocked()

bool ost::Lockfile::isLocked ( void  )

Flag if the current process has aqcuired a lock.

Returns
true if we have the lock.

◆ lock()

bool ost::Lockfile::lock ( const char *  name)

Lock a system-wide name for this process.

If the lock is successful, return true. If an existing lock was already acquired, release it first.

Returns
true if lock successful.
Parameters
namesystem-wide lock to use.

◆ unlock()

void ost::Lockfile::unlock ( void  )

Release an acquired lock.


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