|
KiCad PCB EDA Suite
|
#include <git_transfer.h>
Public Member Functions | |
| KIGIT_TRANSFER ()=default | |
| ~KIGIT_TRANSFER () | |
| KIGIT_TRANSFER (const KIGIT_TRANSFER &)=delete | |
| KIGIT_TRANSFER & | operator= (const KIGIT_TRANSFER &)=delete |
| bool | IsBusy () const |
| True while a transfer started here is still running. | |
| std::weak_ptr< bool > | Alive () const |
| Dropped when this object goes. Hand it to a reporter so its updates stop with it. | |
| 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. | |
Private Attributes | |
| std::shared_ptr< bool > | m_alive = std::make_shared<bool>( true ) |
| Dropped when this object goes, so a transfer that outlives it completes into nothing. | |
| KIGIT_COMMON::CANCEL_TOKEN | m_cancel |
| The token of the transfer started last. | |
| std::shared_ptr< std::function< void()> > | m_completion |
| Created and cleared on the UI thread. | |
| bool | m_busy = false |
Definition at line 93 of file git_transfer.h.
|
default |
Referenced by KIGIT_TRANSFER(), and operator=().
| KIGIT_TRANSFER::~KIGIT_TRANSFER | ( | ) |
Definition at line 93 of file git_transfer.cpp.
References Cancel(), m_alive, and m_completion.
|
delete |
References KIGIT_TRANSFER().
|
inline |
Dropped when this object goes. Hand it to a reporter so its updates stop with it.
Definition at line 106 of file git_transfer.h.
References m_alive.
| void KIGIT_TRANSFER::Cancel | ( | ) |
Ask the running transfer to stop. It finishes on its own time.
Definition at line 103 of file git_transfer.cpp.
References m_cancel.
Referenced by ~KIGIT_TRANSFER().
|
inline |
True while a transfer started here is still running.
Definition at line 103 of file git_transfer.h.
References m_busy.
Referenced by BOOST_AUTO_TEST_CASE().
|
delete |
References KIGIT_TRANSFER().
| bool KIGIT_TRANSFER::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.
aWork is given the cancellation to hand its handler. aDone runs once aWork has returned, and only while this object is still alive, so it may touch the owning window freely. aWork captures must be safe to copy and destroy on a worker. UI references belong only in aDone, including when captures share a context object. False when no thread could be started, which only happens once shutdown has begun.
Definition at line 110 of file git_transfer.cpp.
References KIGIT::CallOnUi(), m_alive, m_busy, m_cancel, m_completion, KIGIT_COMMON::NewCancelToken(), and KIGIT::StartTransfer().
Referenced by BOOST_AUTO_TEST_CASE().
|
private |
Dropped when this object goes, so a transfer that outlives it completes into nothing.
Definition at line 125 of file git_transfer.h.
Referenced by Alive(), Start(), and ~KIGIT_TRANSFER().
|
private |
Definition at line 135 of file git_transfer.h.
|
private |
The token of the transfer started last.
Held so a cancel reaches it even while the task is still queued and has no handler yet.
Definition at line 129 of file git_transfer.h.
|
private |
Created and cleared on the UI thread.
The worker carries only this shared holder, so captured wxWeakRefs are never copied or destroyed on the worker, even during shutdown.
Definition at line 133 of file git_transfer.h.
Referenced by Start(), and ~KIGIT_TRANSFER().