KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGIT_QUERY Class Reference

Read repository state without blocking the UI. More...

#include <git_transfer.h>

Classes

struct  REQUEST
 

Public Member Functions

 KIGIT_QUERY ()=default
 
 ~KIGIT_QUERY ()
 
 KIGIT_QUERY (const KIGIT_QUERY &)=delete
 
KIGIT_QUERY & operator= (const KIGIT_QUERY &)=delete
 
void Run (std::shared_ptr< KIGIT_COMMON > aSession, std::function< void(KIGIT_COMMON &)> aWork, std::function< void()> aDone)
 Run aWork under the session's action lock on a worker, then aDone on the UI thread.
 
void Cancel ()
 Suppress the running completion and discard pending work. Does not wait for a read.
 
bool IsBusy () const
 Remains true until the running worker returns, including after Cancel().
 

Private Member Functions

void start (REQUEST aRequest)
 

Private Attributes

KIGIT_TRANSFER m_transfer
 
std::optional< REQUEST > m_pending
 
uint64_t m_generation = 0
 

Detailed Description

Read repository state without blocking the UI.

All methods are called on the UI thread.

One request runs at a time. A newer request replaces any pending request and suppresses the running request's completion, so a slow read cannot overwrite a newer selection. Closing the owner cancels pending work and never waits for the worker.

Definition at line 146 of file git_transfer.h.

Constructor & Destructor Documentation

◆ KIGIT_QUERY() [1/2]

KIGIT_QUERY::KIGIT_QUERY ( )
default

Referenced by KIGIT_QUERY(), and operator=().

◆ ~KIGIT_QUERY()

KIGIT_QUERY::~KIGIT_QUERY ( )

Definition at line 177 of file git_transfer.cpp.

References Cancel().

◆ KIGIT_QUERY() [2/2]

KIGIT_QUERY::KIGIT_QUERY ( const KIGIT_QUERY & )
delete

References KIGIT_QUERY().

Member Function Documentation

◆ Cancel()

void KIGIT_QUERY::Cancel ( )

Suppress the running completion and discard pending work. Does not wait for a read.

Definition at line 199 of file git_transfer.cpp.

References m_generation, m_pending, and m_transfer.

Referenced by BOOST_AUTO_TEST_CASE(), and ~KIGIT_QUERY().

◆ IsBusy()

bool KIGIT_QUERY::IsBusy ( ) const
inline

Remains true until the running worker returns, including after Cancel().

Definition at line 171 of file git_transfer.h.

References m_transfer.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ operator=()

KIGIT_QUERY & KIGIT_QUERY::operator= ( const KIGIT_QUERY & )
delete

References KIGIT_QUERY().

◆ Run()

void KIGIT_QUERY::Run ( std::shared_ptr< KIGIT_COMMON > aSession,
std::function< void(KIGIT_COMMON &)> aWork,
std::function< void()> aDone )

Run aWork under the session's action lock on a worker, then aDone on the UI thread.

aWork must capture its inputs and result storage by value and must not touch windows. The session stays alive until the worker returns. If it has no repository or is shutting down, aWork is skipped and aDone can display the result's initial, empty state. Exceptions are reported on the UI thread and still deliver aDone. Build each result before assigning it to shared storage so an exception leaves that result empty.

Definition at line 183 of file git_transfer.cpp.

References m_generation, m_pending, m_transfer, and start().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ start()

void KIGIT_QUERY::start ( REQUEST aRequest)
private

Member Data Documentation

◆ m_generation

uint64_t KIGIT_QUERY::m_generation = 0
private

Definition at line 186 of file git_transfer.h.

Referenced by Cancel(), Run(), and start().

◆ m_pending

std::optional<REQUEST> KIGIT_QUERY::m_pending
private

Definition at line 185 of file git_transfer.h.

Referenced by Cancel(), Run(), and start().

◆ m_transfer

KIGIT_TRANSFER KIGIT_QUERY::m_transfer
private

Definition at line 184 of file git_transfer.h.

Referenced by Cancel(), IsBusy(), Run(), and start().


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