|
KiCad PCB EDA Suite
|
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 |
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.
|
default |
Referenced by KIGIT_QUERY(), and operator=().
| KIGIT_QUERY::~KIGIT_QUERY | ( | ) |
Definition at line 177 of file git_transfer.cpp.
References Cancel().
|
delete |
References KIGIT_QUERY().
| 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().
|
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().
|
delete |
References KIGIT_QUERY().
| 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().
|
private |
Definition at line 207 of file git_transfer.cpp.
References _, KIGIT_QUERY::REQUEST::done, KIGIT_QUERY::REQUEST::generation, m_generation, m_pending, m_transfer, next(), KIGIT_QUERY::REQUEST::session, start(), and KIGIT_QUERY::REQUEST::work.
|
private |
Definition at line 186 of file git_transfer.h.
|
private |
Definition at line 185 of file git_transfer.h.
|
private |