Kea 2.5.8
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.
 
virtual ~InterprocessSyncFile ()
 Destructor.
 
- Public Member Functions inherited from isc::log::interprocess::InterprocessSync
 InterprocessSync (const std::string &task_name)
 Constructor.
 
virtual ~InterprocessSync ()
 Destructor.
 

Protected Member Functions

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

Additional Inherited Members

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

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.

◆ ~InterprocessSyncFile()

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

Destructor.

Definition at line 31 of file interprocess_sync_file.cc.

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: