Kea  2.3.5-git
isc::log::interprocess::InterprocessSyncFile Class Reference

File-based Interprocess Sync Class. More...

#include <interprocess_sync_file.h>

+ Inheritance diagram for isc::log::interprocess::InterprocessSyncFile:

Public Member Functions

 InterprocessSyncFile (const std::string &task_name)
 Constructor. More...
 
virtual ~InterprocessSyncFile ()
 Destructor. More...
 
- Public Member Functions inherited from isc::log::interprocess::InterprocessSync
 InterprocessSync (const std::string &task_name)
 Constructor. More...
 
virtual ~InterprocessSync ()
 Destructor. More...
 

Protected Member Functions

bool lock ()
 Acquire the lock (blocks if something else has acquired a lock on the same task name) More...
 
bool tryLock ()
 Try to acquire a lock (doesn't block) More...
 
bool unlock ()
 Release the lock. More...
 

Additional Inherited Members

- Protected Attributes inherited from isc::log::interprocess::InterprocessSync
bool is_locked_
 Is the lock taken? More...
 
const std::string task_name_
 The task name. More...
 

Detailed Description

File-based Interprocess Sync Class.

This class specifies a concrete implementation for a file-based interprocess synchronization mechanism. Please see the InterprocessSync class documentation for usage.

An InterprocessSyncFileError exception may be thrown if there is an issue opening the lock file.

Lock files are created typically in the local state directory (var). They are typically named like "<task_name>_lockfile". This implementation opens lock files lazily (only when necessary). It also leaves the lock files lying around as multiple processes may have locks on them.

Definition at line 42 of file interprocess_sync_file.h.

Constructor & Destructor Documentation

◆ InterprocessSyncFile()

isc::log::interprocess::InterprocessSyncFile::InterprocessSyncFile ( const std::string &  task_name)
inline

Constructor.

Creates a file-based interprocess synchronization object

Parameters
task_nameName of the synchronization task. This has to be identical among the various processes that need to be synchronized for the same task.

Definition at line 51 of file interprocess_sync_file.h.

References fd_.

◆ ~InterprocessSyncFile()

isc::log::interprocess::InterprocessSyncFile::~InterprocessSyncFile ( )
virtual

Destructor.

Definition at line 31 of file interprocess_sync_file.cc.

References fd_, isc_throw, and isc::log::interprocess::InterprocessSync::task_name_.

Member Function Documentation

◆ lock()

bool isc::log::interprocess::InterprocessSyncFile::lock ( )
protectedvirtual

Acquire the lock (blocks if something else has acquired a lock on the same task name)

Returns
Returns true if the lock was acquired, false otherwise.

Implements isc::log::interprocess::InterprocessSync.

Definition at line 89 of file interprocess_sync_file.cc.

References isc::log::interprocess::InterprocessSync::is_locked_.

◆ tryLock()

bool isc::log::interprocess::InterprocessSyncFile::tryLock ( )
protectedvirtual

Try to acquire a lock (doesn't block)

Returns
Returns true if the lock was acquired, false otherwise.

Implements isc::log::interprocess::InterprocessSync.

Definition at line 103 of file interprocess_sync_file.cc.

References isc::log::interprocess::InterprocessSync::is_locked_.

◆ unlock()

bool isc::log::interprocess::InterprocessSyncFile::unlock ( )
protectedvirtual

Release the lock.

Returns
Returns true if the lock was released, false otherwise.

Implements isc::log::interprocess::InterprocessSync.

Definition at line 117 of file interprocess_sync_file.cc.

References isc::log::interprocess::InterprocessSync::is_locked_.


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