Kea 3.1.3
isc::util::PIDLock Class Reference

RAII device to handle a lock file to avoid race conditions. More...

#include <pid_file.h>

Public Member Functions

 PIDLock (const std::string &lockname, bool blocking=false)
 Constructor.
 
 ~PIDLock ()
 Destructor.
 
bool isLocked ()
 Return the lock status.
 

Detailed Description

RAII device to handle a lock file to avoid race conditions.

Note
If there is a missing component in the path and the lock is not blocking the lock is considered as being acquired: this does not change the behavior of PIDFile methods (check() will succeed and write() throw) and does not require unit test updates as if the constructor throws.

Definition at line 115 of file pid_file.h.

Constructor & Destructor Documentation

◆ PIDLock()

isc::util::PIDLock::PIDLock ( const std::string & lockname,
bool blocking = false )

Constructor.

Try to get a lock.

Parameters
locknameLock filename.
blockingIf true (default is false) block when already locked.

Definition at line 89 of file pid_file.cc.

References isc_throw.

◆ ~PIDLock()

isc::util::PIDLock::~PIDLock ( )

Destructor.

Release the lock when taken and delete the lock file.

Definition at line 117 of file pid_file.cc.

Member Function Documentation

◆ isLocked()

bool isc::util::PIDLock::isLocked ( )
inline

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