KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGIT::REPO_ACTION_LOCK Class Reference

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ REPO_ACTION_LOCK() [1/2]

KIGIT::REPO_ACTION_LOCK::REPO_ACTION_LOCK ( const std::filesystem::path & aCommonDir,
const char * aName = "kicad-action" )
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().

◆ ~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().

◆ REPO_ACTION_LOCK() [2/2]

KIGIT::REPO_ACTION_LOCK::REPO_ACTION_LOCK ( const REPO_ACTION_LOCK & )
delete

References REPO_ACTION_LOCK().

Member Function Documentation

◆ Acquire()

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=().

◆ Error()

const std::string & KIGIT::REPO_ACTION_LOCK::Error ( ) const
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.

◆ Held()

bool KIGIT::REPO_ACTION_LOCK::Held ( ) const
inline

Definition at line 82 of file kigit_lock_retry.h.

References m_held.

◆ operator=()

REPO_ACTION_LOCK & KIGIT::REPO_ACTION_LOCK::operator= ( const REPO_ACTION_LOCK & )
delete

◆ Release()

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().

◆ TryAcquire()

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().

Member Data Documentation

◆ m_error

std::string KIGIT::REPO_ACTION_LOCK::m_error
private

Definition at line 93 of file kigit_lock_retry.h.

Referenced by Error(), and TryAcquire().

◆ m_fd

int KIGIT::REPO_ACTION_LOCK::m_fd = -1
private

Definition at line 91 of file kigit_lock_retry.h.

Referenced by Release(), and TryAcquire().

◆ m_held

bool KIGIT::REPO_ACTION_LOCK::m_held = false
private

Definition at line 92 of file kigit_lock_retry.h.

Referenced by Held(), Release(), and TryAcquire().

◆ m_path

std::filesystem::path KIGIT::REPO_ACTION_LOCK::m_path
private

Definition at line 90 of file kigit_lock_retry.h.

Referenced by TryAcquire().


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