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 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 | ) |
|---|
◆ ~LockFileManager()
| LockFileManager::~LockFileManager ( ) | override |
|---|
◆ tryLock()
| Expected< bool > LockFileManager::tryLock ( ) | overridevirtual |
|---|
Tries to acquire the lock without blocking.
Returns
true if the lock was successfully acquired, false if the lock is already held by someone else, or [Error](classllvm%5F1%5F1Error.html "Lightweight error class with error context and mandatory checking.") 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().
◆ unsafeMaybeUnlock()
| std::error_code LockFileManager::unsafeMaybeUnlock ( ) | overridevirtual |
|---|
◆ waitForUnlockFor()
| WaitForUnlockResult LockFileManager::waitForUnlockFor ( std::chrono::seconds MaxSeconds) | overridevirtual |
|---|
The documentation for this class was generated from the following files:
- include/llvm/Support/LockFileManager.h
- lib/Support/LockFileManager.cpp