43void CallOnUi( std::function<
void()> aFn );
47void CallIfAlive(
const std::weak_ptr<bool>& aWatch, std::function<
void()> aFn );
56bool StartTransfer(
const std::string& aLabel, std::function<
void()> aWork );
81 KIGIT_STATUS_REPORTER(
const std::weak_ptr<bool>& aAlive, std::function<
void(
const wxString& )> aShow );
88 std::function<void(
const wxString& )>
m_show;
121 const std::function<
void()>& aDone );
125 std::shared_ptr<bool>
m_alive = std::make_shared<bool>(
true );
164 void Run( std::shared_ptr<KIGIT_COMMON> aSession, std::function<
void(
KIGIT_COMMON& )> aWork,
165 std::function<
void()> aDone );
The project's git session.
std::shared_ptr< std::atomic< bool > > CANCEL_TOKEN
One token per operation.
bool IsBusy() const
Remains true until the running worker returns, including after Cancel().
KIGIT_TRANSFER m_transfer
KIGIT_QUERY(const KIGIT_QUERY &)=delete
void Cancel()
Suppress the running completion and discard pending work. Does not wait for a read.
KIGIT_QUERY & operator=(const KIGIT_QUERY &)=delete
std::optional< REQUEST > m_pending
void start(REQUEST aRequest)
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.
std::function< void(const wxString &)> m_show
std::weak_ptr< bool > m_alive
KIGIT_STATUS_REPORTER(const std::weak_ptr< bool > &aAlive, std::function< void(const wxString &)> aShow)
std::weak_ptr< bool > Alive() const
Dropped when this object goes. Hand it to a reporter so its updates stop with it.
KIGIT_TRANSFER(const KIGIT_TRANSFER &)=delete
KIGIT_COMMON::CANCEL_TOKEN m_cancel
The token of the transfer started last.
KIGIT_TRANSFER & operator=(const KIGIT_TRANSFER &)=delete
std::shared_ptr< std::function< void()> > m_completion
Created and cleared on the UI thread.
std::shared_ptr< bool > m_alive
Dropped when this object goes, so a transfer that outlives it completes into nothing.
bool IsBusy() const
True while a transfer started here is still running.
void Cancel()
Ask the running transfer to stop. It finishes on its own time.
bool Start(const std::string &aLabel, const std::function< void(const KIGIT_COMMON::CANCEL_TOKEN &)> &aWork, const std::function< void()> &aDone)
Run aWork on a background thread, then aDone on the UI thread.
PROGRESS_REPORTER_BASE(int aNumPhases)
bool StartTransfer(const std::string &aLabel, std::function< void()> aWork)
Run aWork on a thread the orphan registry owns.
void CallIfAlive(const std::weak_ptr< bool > &aWatch, std::function< void()> aFn)
As CallOnUi, for work that touches the window that started the transfer.
void CallOnUi(std::function< void()> aFn)
Run aFn on the UI thread.
std::function< void()> done
std::function< void(KIGIT_COMMON &)> work
std::shared_ptr< KIGIT_COMMON > session