class Gambit::Utils::FileLock

[No description available] More…

#include <file_lock.hpp>

Inherited by Gambit::Utils::ProcessLock

Public Functions

Name
FileLock(const std::string & fname, const bool is_exhaustible =false, const bool harderrs =false)
Constructor.
~FileLock()
voidget_lock()
Obtain lock (or wait if lock cannot be obtained, and then obtain lock)
voidrelease_lock()
Release a lock (error if no lock held)
const std::string &get_filename() const
Getter for lockfile name.
boolexhausted()
Check if lock is exhausted.

Detailed Description

class Gambit::Utils::FileLock;

Class to manage a file lock Lock will be automatically released if this object is destructed

Public Functions Documentation

function FileLock

FileLock(
    const std::string & fname,
    const bool is_exhaustible =false,
    const bool harderrs =false
)

Constructor.

Should check for errors opening the file. List of error codes is kind of long though, let people look it up themselves for now…

Error opening file!

function ~FileLock

~FileLock()

Destructor Closing the file descriptor will automatically release any lock we might have

Error closing file!

function get_lock

void get_lock()

Obtain lock (or wait if lock cannot be obtained, and then obtain lock)

Already have the lock!

Ok it seems there are some errors that we should handle, and then just try again to obtain the lock.

function release_lock

void release_lock()

Release a lock (error if no lock held)

Don’t have the lock!

Release the lock

function get_filename

const std::string & get_filename() const

Getter for lockfile name.

function exhausted

bool exhausted()

Check if lock is exhausted.

Don’t have the lock!


Updated on 2024-07-18 at 13:53:32 +0000