|
KiCad PCB EDA Suite
|
A process's lock on $GIT_COMMON_DIR/kicad-action, held while it rewrites the files, the index or HEAD in more than one step, so no other process sees a branch switch half done. More...
#include <kigit_lock_retry.h>
Public Member Functions | |
| REPO_ACTION_LOCK (const std::filesystem::path &aCommonDir, const char *aName="kicad-action") | |
| aCommonDir is as git_repository_commondir gives it. aName picks an independent lock in that directory. | |
| ~REPO_ACTION_LOCK () | |
| REPO_ACTION_LOCK (const REPO_ACTION_LOCK &)=delete | |
| REPO_ACTION_LOCK & | operator= (const REPO_ACTION_LOCK &)=delete |
| int | TryAcquire () |
| Try once without waiting. 0 once held, GIT_ELOCKED while another holder has it, GIT_ERROR otherwise. | |
| int | Acquire (std::chrono::milliseconds aBudget=BACKEND_LOCK_BUDGET) |
| TryAcquire again after each contention until it is held, fails otherwise, or aBudget is spent. | |
| bool | Held () const |
| const std::string & | Error () const |
| Why the last TryAcquire could not use the lock file, or empty when it could. | |
| void | Release () |
Private Attributes | |
| std::filesystem::path | m_path |
| int | m_fd = -1 |
| bool | m_held = false |
| std::string | m_error |
A process's lock on $GIT_COMMON_DIR/kicad-action, held while it rewrites the files, the index or HEAD in more than one step, so no other process sees a branch switch half done.
The OS releases it with the process. A network filesystem may not honour it.
Definition at line 66 of file kigit_lock_retry.h.
|
explicit |
aCommonDir is as git_repository_commondir gives it. aName picks an independent lock in that directory.
References REPO_ACTION_LOCK().
Referenced by operator=(), REPO_ACTION_LOCK(), and REPO_ACTION_LOCK().
| KIGIT::REPO_ACTION_LOCK::~REPO_ACTION_LOCK | ( | ) |
Definition at line 348 of file kigit_lock_retry.cpp.
References Release(), and ~REPO_ACTION_LOCK().
Referenced by ~REPO_ACTION_LOCK().
|
delete |
References REPO_ACTION_LOCK().
| int KIGIT::REPO_ACTION_LOCK::Acquire | ( | std::chrono::milliseconds | aBudget = BACKEND_LOCK_BUDGET | ) |
TryAcquire again after each contention until it is held, fails otherwise, or aBudget is spent.
Definition at line 414 of file kigit_lock_retry.cpp.
References Acquire(), TryAcquire(), and KIGIT::WithLockRetry().
Referenced by Acquire(), and operator=().
|
inline |
Why the last TryAcquire could not use the lock file, or empty when it could.
Definition at line 85 of file kigit_lock_retry.h.
References m_error.
|
inline |
Definition at line 82 of file kigit_lock_retry.h.
References m_held.
|
delete |
References Acquire(), KIGIT::BACKEND_LOCK_BUDGET, REPO_ACTION_LOCK(), and TryAcquire().
| void KIGIT::REPO_ACTION_LOCK::Release | ( | ) |
Definition at line 424 of file kigit_lock_retry.cpp.
References m_fd, m_held, and Release().
Referenced by Release(), and ~REPO_ACTION_LOCK().
| int KIGIT::REPO_ACTION_LOCK::TryAcquire | ( | ) |
Try once without waiting. 0 once held, GIT_ELOCKED while another holder has it, GIT_ERROR otherwise.
Definition at line 354 of file kigit_lock_retry.cpp.
References locked, m_error, m_fd, m_held, m_path, and TryAcquire().
Referenced by Acquire(), operator=(), and TryAcquire().
|
private |
Definition at line 93 of file kigit_lock_retry.h.
Referenced by Error(), and TryAcquire().
|
private |
Definition at line 91 of file kigit_lock_retry.h.
Referenced by Release(), and TryAcquire().
|
private |
Definition at line 92 of file kigit_lock_retry.h.
Referenced by Held(), Release(), and TryAcquire().
|
private |
Definition at line 90 of file kigit_lock_retry.h.
Referenced by TryAcquire().