LLVM: llvm::LockFileManager Class Reference (original) (raw)

Class that manages the creation of a lock file to aid implicit coordination between different processes. More...

#include "[llvm/Support/LockFileManager.h](LockFileManager%5F8h%5Fsource.html)"

Public Types
enum LockFileState { LFS_Owned, LFS_Shared, LFS_Error }
Describes the state of a lock file. More...
enum WaitForUnlockResult { Res_Success, Res_OwnerDied, Res_Timeout }
Describes the result of waiting for the owner to release the lock. More...
Public Member Functions
LockFileManager (StringRef FileName)
~LockFileManager ()
LockFileState getState () const
Determine the state of the lock file.
operator LockFileState () const
WaitForUnlockResult waitForUnlock (const unsigned MaxSeconds=90)
For a shared lock, wait until the owner releases the lock.
std::error_code unsafeRemoveLockFile ()
Remove the lock file.
std::string getErrorMessage () const
Get error message, or "" if there is no error.
void setError (const std::error_code &EC, StringRef ErrorMsg="")
Set error and error message.

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 27 of file LockFileManager.h.

LockFileState

Describes the state of a lock file.

Enumerator
LFS_Owned The lock file has been created and is owned by this instance of the object.
LFS_Shared The lock file already exists and is owned by some other instance.
LFS_Error An error occurred while trying to create or find the lock file.

Definition at line 30 of file LockFileManager.h.

WaitForUnlockResult

Describes the result of waiting for the owner to release the lock.

Enumerator
Res_Success The lock was released successfully.
Res_OwnerDied Owner died while holding the lock.
Res_Timeout Reached timeout while waiting for the owner to release the lock.

Definition at line 43 of file LockFileManager.h.

LockFileManager::LockFileManager ( StringRef FileName )

Definition at line 160 of file LockFileManager.cpp.

References llvm::raw_fd_ostream::clear_error(), llvm::raw_fd_ostream::close(), llvm::sys::fs::create_link(), llvm::sys::fs::createUniqueFile(), llvm::raw_fd_ostream::error(), llvm::sys::fs::exists(), llvm::file_exists, getHostID(), llvm::sys::Process::getProcessId(), llvm::raw_fd_ostream::has_error(), llvm::sys::fs::make_absolute(), llvm::sys::fs::remove(), setError(), and llvm::SmallString< InternalLen >::str().

~LockFileManager()

LockFileManager::~LockFileManager ( )

getErrorMessage()

std::string LockFileManager::getErrorMessage ( ) const

getState()

operator LockFileState()

setError()

void llvm::LockFileManager::setError ( const std::error_code & EC, StringRef ErrorMsg = "" ) inline

unsafeRemoveLockFile()

std::error_code LockFileManager::unsafeRemoveLockFile ( )

waitForUnlock()

For a shared lock, wait until the owner releases the lock.

Total timeout for the file to appear is ~1.5 minutes.

Parameters

MaxSeconds the maximum total wait time in seconds.

Definition at line 295 of file LockFileManager.cpp.

References llvm::sys::fs::access(), llvm::SmallString< InternalLen >::c_str(), llvm::sys::fs::Exist, llvm::sys::fs::exists(), getState(), LFS_Shared, llvm::no_such_file_or_directory, Res_OwnerDied, Res_Success, Res_Timeout, and llvm::ExponentialBackoff::waitForNextAttempt().

Referenced by llvm::AMDGPUSplitModulePass::run().


The documentation for this class was generated from the following files: