top | up | prev | next

FileLockTable Class

Definition at line 19 of FileLocking.cpp

Constructors

FileLockTable()

Member Functions

void Done() static
void Init() static
FileLockTable& Instance() static
void LockFile(const std::string& filePath, LockKind lockKind)
bool NoReaders(const std::string& filePath)
bool NoWriters(const std::string& filePath)
void UnlockFile(const std::string& filePath, LockKind lockKind)

Member Variables

std::unique_ptr<FileLockTable> instance static
std::mutex mtx
std::map<std::string, int> readMap
std::condition_variable releaseRead
std::condition_variable releaseWrite
bool waitingReadLock
bool waitingWriteLock
std::set<std::string> writeLocks

Constructor Details

FileLockTable Constructor

soulng::util::FileLockTable::FileLockTable()

Definition at line 43 of FileLocking.cpp :
 43 : waitingReadLock(false)waitingWriteLock(false)
 44 {
 45 }


Declaration at line 31 of FileLocking.cpp


Member Function Details

Done Member Function

void soulng::util::FileLockTable::Done() static

Definition at line 52 of FileLocking.cpp :
 53 {
 54     instance.reset();
 55 }


Declaration at line 23 of FileLocking.cpp


Init Member Function

void soulng::util::FileLockTable::Init() static

Definition at line 47 of FileLocking.cpp :
 48 {
 49     instance.reset(new FileLockTable());
 50 }


Declaration at line 22 of FileLocking.cpp


Instance Member Function

FileLockTable & soulng::util::FileLockTable::Instance() static

Definition at line 24 of FileLocking.cpp :
 24 { return *instance; }


LockFile Member Function

void soulng::util::FileLockTable::LockFile(const std::string& filePath, LockKind lockKind)

Definition at line 57 of FileLocking.cpp
Declaration at line 25 of FileLocking.cpp

Calls: soulng::util::FileLockTable::NoReaders , soulng::util::FileLockTable::NoWriters


NoReaders Member Function

bool soulng::util::FileLockTable::NoReaders(const std::string& filePath)

Definition at line 121 of FileLocking.cpp :
122 {
123     auto it = readMap.find(filePath);
124     if (it != readMap.end())
125     {
126         int numReaders = it->second;
127         return numReaders == 0;
128     }
129     return true;
130 }


Declaration at line 27 of FileLocking.cpp

Called by: soulng::util::FileLockTable::LockFile


NoWriters Member Function

bool soulng::util::FileLockTable::NoWriters(const std::string& filePath)

Definition at line 132 of FileLocking.cpp :
133 {
134     return writeLocks.find(filePath) == writeLocks.cend();
135 }


Declaration at line 28 of FileLocking.cpp

Called by: soulng::util::FileLockTable::LockFile


UnlockFile Member Function

void soulng::util::FileLockTable::UnlockFile(const std::string& filePath, LockKind lockKind)

Definition at line 137 of FileLocking.cpp
Declaration at line 26 of FileLocking.cpp


top | up | prev | next