|
LLVM 22.0.0git
|
Class that manages the creation of a lock file to aid implicit coordination between different processes. More...
#include "llvm/Support/LockFileManager.h"
Public Member Functions | |
| LockFileManager (StringRef FileName) | |
| Does not try to acquire the lock. | |
| Expected< bool > | tryLock () override |
| Tries to acquire the lock without blocking. | |
| WaitForUnlockResult | waitForUnlockFor (std::chrono::seconds MaxSeconds) override |
| For a shared lock, wait until the owner releases the lock. | |
| std::error_code | unsafeMaybeUnlock () override |
| Remove the lock file. | |
| ~LockFileManager () override | |
Unlocks the lock if previously acquired by tryLock(). | |
| Public Member Functions inherited from llvm::AdvisoryLock | |
| virtual | ~AdvisoryLock ()=default |
Unlocks the lock if its ownership was previously acquired by tryLock(). | |
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, 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.
| LockFileManager::LockFileManager | ( | StringRef | FileName | ) |
Does not try to acquire the lock.
Definition at line 160 of file LockFileManager.cpp.
|
override |
Unlocks the lock if previously acquired by tryLock().
Definition at line 248 of file LockFileManager.cpp.
References llvm::sys::DontRemoveFileOnSignal(), and llvm::sys::fs::remove().
Tries to acquire the lock without blocking.
Error in case of unexpected failure. Implements llvm::AdvisoryLock.
Definition at line 163 of file LockFileManager.cpp.
References assert(), llvm::raw_fd_ostream::clear_error(), llvm::raw_fd_ostream::close(), llvm::sys::fs::create_link(), llvm::createStringError(), 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(), and llvm::sys::fs::remove().
Referenced by llvm::AMDGPUSplitModulePass::run().
|
overridevirtual |
Remove the lock file.
This may delete a different lock file than the one previously read if there is a race.
Implements llvm::AdvisoryLock.
Definition at line 290 of file LockFileManager.cpp.
References llvm::sys::fs::remove().
Referenced by llvm::AMDGPUSplitModulePass::run().
|
overridevirtual |
For a shared lock, wait until the owner releases the lock.
| MaxSeconds | the maximum total wait time in seconds. |
Implements llvm::AdvisoryLock.
Definition at line 261 of file LockFileManager.cpp.
References llvm::sys::fs::access(), assert(), llvm::sys::fs::Exist, llvm::no_such_file_or_directory, llvm::OwnerDied, llvm::Success, llvm::Timeout, and llvm::ExponentialBackoff::waitForNextAttempt().
Referenced by llvm::AMDGPUSplitModulePass::run().