LLVM API Documentation
Class that manages the creation of a lock file to aid implicit coordination between different processes. More...
#include <LockFileManager.h>
Public Types | |
enum | LockFileState { LFS_Owned, LFS_Shared, LFS_Error } |
Describes the state of a lock file. More... | |
Public Member Functions | |
LockFileManager (StringRef FileName) | |
~LockFileManager () | |
LockFileState | getState () const |
Determine the state of the lock file. More... | |
operator LockFileState () const | |
void | waitForUnlock () |
For a shared lock, wait until the owner releases the lock. More... | |
Class that manages the creation of a lock file to aid implicit coordination between different processes.
The implicit coordination works by creating a ".lock" file alongside the file that we're coordinating for, using the atomicity of the file system to ensure that only a single process can create that ".lock" file. When the lock file is removed, the owning process has finished the operation.
Definition at line 28 of file LockFileManager.h.
Describes the state of a lock file.
Definition at line 31 of file LockFileManager.h.
LockFileManager::LockFileManager | ( | StringRef | FileName | ) |
Definition at line 71 of file LockFileManager.cpp.
References llvm::SmallString< InternalLen >::c_str(), llvm::raw_fd_ostream::close(), llvm::sys::fs::create_hard_link(), llvm::sys::fs::createUniqueFile(), llvm::lltok::Error, llvm::raw_fd_ostream::has_error(), llvm::make_error_code(), llvm::errc::no_space_on_device, llvm::sys::fs::remove(), llvm::LibFunc::stat, llvm::StringRef::str(), llvm::SmallString< InternalLen >::str(), and llvm::errc::success.
LockFileManager::~LockFileManager | ( | ) |
Definition at line 161 of file LockFileManager.cpp.
References getState(), LFS_Owned, llvm::sys::fs::remove(), llvm::StringRef::str(), and llvm::SmallString< InternalLen >::str().
LockFileManager::LockFileState LockFileManager::getState | ( | ) | const |
Determine the state of the lock file.
Definition at line 151 of file LockFileManager.cpp.
References llvm::lltok::Error, LFS_Error, LFS_Owned, and LFS_Shared.
Referenced by operator LockFileState(), waitForUnlock(), and ~LockFileManager().
|
inline |
Definition at line 67 of file LockFileManager.h.
References getState().
void LockFileManager::waitForUnlock | ( | ) |
For a shared lock, wait until the owner releases the lock.
Definition at line 171 of file LockFileManager.cpp.
References llvm::sys::fs::exists(), getState(), LFS_Shared, llvm::StringRef::str(), and llvm::SmallString< InternalLen >::str().