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

#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
 

Detailed Description

Definition at line 93 of file git_transfer.h.

Constructor & Destructor Documentation

◆ KIGIT_TRANSFER() [1/2]

KIGIT_TRANSFER::KIGIT_TRANSFER ( )
default

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

◆ ~KIGIT_TRANSFER()

KIGIT_TRANSFER::~KIGIT_TRANSFER ( )

Definition at line 93 of file git_transfer.cpp.

References Cancel(), m_alive, and m_completion.

◆ KIGIT_TRANSFER() [2/2]

KIGIT_TRANSFER::KIGIT_TRANSFER ( const KIGIT_TRANSFER & )
delete

References KIGIT_TRANSFER().

Member Function Documentation

◆ Alive()

std::weak_ptr< bool > KIGIT_TRANSFER::Alive ( ) const
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.

◆ Cancel()

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

◆ IsBusy()

bool KIGIT_TRANSFER::IsBusy ( ) const
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().

◆ operator=()

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

References KIGIT_TRANSFER().

◆ Start()

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

Member Data Documentation

◆ m_alive

std::shared_ptr<bool> KIGIT_TRANSFER::m_alive = std::make_shared<bool>( true )
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().

◆ m_busy

bool KIGIT_TRANSFER::m_busy = false
private

Definition at line 135 of file git_transfer.h.

Referenced by IsBusy(), and Start().

◆ m_cancel

KIGIT_COMMON::CANCEL_TOKEN KIGIT_TRANSFER::m_cancel
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.

Referenced by Cancel(), and Start().

◆ m_completion

std::shared_ptr<std::function<void()> > KIGIT_TRANSFER::m_completion
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().


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