28 std::function<
void()> aCancel )
31 static uint64_t s_nextId = 0;
38 transfers.
m_live.emplace(
m_id,
LIVE{ aStatus, std::move( aCancel ) } );
45 std::shared_ptr<KIGIT_COMMON> repo = std::exchange(
m_repo, {} ).lock();
46 uint64_t
id = std::exchange(
m_id, 0 );
48 if( repo && repo->Transfers().m_live.erase(
id ) )
61 for(
auto it =
m_live.rbegin(); it !=
m_live.rend(); ++it )
63 if( it->first != aExcept.
m_id )
64 return it->second.status;
73 for(
const auto& [
id, live] :
m_live )
75 if(
id != aExcept.
m_id && live.cancel )
85 std::vector<std::function<void()>> cancels;
87 for(
auto& [
id, live] :
m_live )
90 cancels.push_back( std::exchange( live.cancel,
nullptr ) );
94 for( std::function<
void()>&
cancel : cancels )
One transfer's hold on its repository, released when reset, begun again or destroyed.
void Begin(const std::shared_ptr< KIGIT_COMMON > &aRepo, const wxString &aStatus, std::function< void()> aCancel)
Release any earlier hold, then hold aRepo busy for one transfer.
std::weak_ptr< KIGIT_COMMON > m_repo
friend class GIT_TRANSFER_BUSY
wxString Status(const HOLD &aExcept) const
The status of the latest live transfer other than aExcept's, or empty when none is.
void CancelAll()
Call each live transfer's cancel once. They stay live until their owners end them.
bool CanCancel(const HOLD &aExcept) const
True while a live transfer other than aExcept's has a cancel that has not been called.
std::map< uint64_t, LIVE > m_live
Keyed by an id that only grows, so the last entry is the latest transfer.
bool IsBusy(const HOLD &aExcept) const
True while a transfer other than aExcept's is live.
virtual void OnGitTransfersChanged()=0
void Notify(void(ObserverInterface::*Ptr)(Args1...), Args2 &&... aArgs)
Notify event to all subscribed observers.