class LockFileManager
Declaration
class LockFileManager { /* full declaration omitted */ };
Description
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.
Declared at: llvm/include/llvm/Support/LockFileManager.h:27
Member Variables
- private SmallString<128> FileName
- private SmallString<128> LockFileName
- private SmallString<128> UniqueLockFileName
- private Optional<std::pair<std::string, int>> Owner
- private std::error_code ErrorCode
- private std::string ErrorDiagMsg
Method Overview
- private LockFileManager(const llvm::LockFileManager &)
- public LockFileManager(llvm::StringRef FileName)
- public std::string getErrorMessage() const
- public llvm::LockFileManager::LockFileState getState() const
- public llvm::LockFileManager::LockFileState operator llvm::LockFileManager::LockFileState() const
- private static bool processStillExecuting(llvm::StringRef Hostname, int PID)
- private static Optional<std::pair<std::string, int>> readLockFile(llvm::StringRef LockFileName)
- public void setError(const std::error_code & EC, llvm::StringRef ErrorMsg = "")
- public std::error_code unsafeRemoveLockFile()
- public llvm::LockFileManager::WaitForUnlockResult waitForUnlock(const unsigned int MaxSeconds = 90)
- public ~LockFileManager()
Methods
¶LockFileManager(const llvm::LockFileManager&)
LockFileManager(const llvm::LockFileManager&)
Declared at: llvm/include/llvm/Support/LockFileManager.h:61
Parameters
- const llvm::LockFileManager&
¶LockFileManager(llvm::StringRef FileName)
LockFileManager(llvm::StringRef FileName)
Declared at: llvm/include/llvm/Support/LockFileManager.h:71
Parameters
- llvm::StringRef FileName
¶std::string getErrorMessage() const
std::string getErrorMessage() const
Description
Get error message, or "" if there is no error.
Declared at: llvm/include/llvm/Support/LockFileManager.h:89
¶llvm::LockFileManager::LockFileState getState()
const
llvm::LockFileManager::LockFileState getState()
const
Description
Determine the state of the lock file.
Declared at: llvm/include/llvm/Support/LockFileManager.h:75
¶llvm::LockFileManager::LockFileState
operator llvm::LockFileManager::LockFileState()
const
llvm::LockFileManager::LockFileState
operator llvm::LockFileManager::LockFileState()
const
Declared at: llvm/include/llvm/Support/LockFileManager.h:77
¶static bool processStillExecuting(
llvm::StringRef Hostname,
int PID)
static bool processStillExecuting(
llvm::StringRef Hostname,
int PID)
Declared at: llvm/include/llvm/Support/LockFileManager.h:67
Parameters
- llvm::StringRef Hostname
- int PID
¶static Optional<std::pair<std::string, int>>
readLockFile(llvm::StringRef LockFileName)
static Optional<std::pair<std::string, int>>
readLockFile(llvm::StringRef LockFileName)
Description
Attempt to read the lock file with the given name, if it exists.
Declared at: llvm/include/llvm/Support/LockFileManager.h:65
Parameters
- llvm::StringRef LockFileName
- The name of the lock file to read.
Returns
The process ID of the process that owns this lock file
¶void setError(const std::error_code& EC,
llvm::StringRef ErrorMsg = "")
void setError(const std::error_code& EC,
llvm::StringRef ErrorMsg = "")
Description
Set error and error message
Declared at: llvm/include/llvm/Support/LockFileManager.h:92
Parameters
- const std::error_code& EC
- llvm::StringRef ErrorMsg = ""
¶std::error_code unsafeRemoveLockFile()
std::error_code unsafeRemoveLockFile()
Description
Remove the lock file. This may delete a different lock file than the one previously read if there is a race.
Declared at: llvm/include/llvm/Support/LockFileManager.h:86
¶llvm::LockFileManager::WaitForUnlockResult
waitForUnlock(const unsigned int MaxSeconds = 90)
llvm::LockFileManager::WaitForUnlockResult
waitForUnlock(const unsigned int MaxSeconds = 90)
Description
For a shared lock, wait until the owner releases the lock. Total timeout for the file to appear is ~1.5 minutes.
Declared at: llvm/include/llvm/Support/LockFileManager.h:82
Parameters
- const unsigned int MaxSeconds = 90
- the maximum total wait time in seconds.
¶~LockFileManager()
~LockFileManager()
Declared at: llvm/include/llvm/Support/LockFileManager.h:72