simplify trigger_unchoke and trigger_optimistic_unchoke on session_impl, abd make them noexcept

This commit is contained in:
arvidn 2017-11-11 16:45:27 +01:00 committed by Arvid Norberg
parent 94dcd8e14b
commit b6a73eeaaa
5 changed files with 12 additions and 14 deletions

View File

@ -549,12 +549,12 @@ namespace aux {
int peak_up_rate() const { return m_peak_up_rate; }
void trigger_unchoke() override
void trigger_unchoke() noexcept override
{
TORRENT_ASSERT(is_single_thread());
m_unchoke_time_scaler = 0;
}
void trigger_optimistic_unchoke() override
void trigger_optimistic_unchoke() noexcept override
{
TORRENT_ASSERT(is_single_thread());
m_optimistic_unchoke_time_scaler = 0;

View File

@ -186,8 +186,8 @@ namespace libtorrent { namespace aux {
virtual bool is_aborted() const = 0;
virtual int num_uploads() const = 0;
virtual bool preemptive_unchoke() const = 0;
virtual void trigger_optimistic_unchoke() = 0;
virtual void trigger_unchoke() = 0;
virtual void trigger_optimistic_unchoke() noexcept = 0;
virtual void trigger_unchoke() noexcept = 0;
virtual std::weak_ptr<torrent> find_torrent(sha1_hash const& info_hash) const = 0;
virtual std::weak_ptr<torrent> find_disconnect_candidate_torrent() const = 0;

View File

@ -33,12 +33,12 @@ namespace libtorrent {
}
catch (std::exception const& err)
{
std::fprintf(stderr, "invariant_check failed with exception: %s"
std::fprintf(stderr, "invariant_check failed with exception: %s\n"
, err.what());
}
catch (...)
{
std::fprintf(stderr, "invariant_check failed with exception");
std::fprintf(stderr, "invariant_check failed with exception\n");
}
#else
invariant_access::check_invariant(x);

View File

@ -642,8 +642,8 @@ namespace libtorrent {
bool choke_peer(peer_connection& c);
bool unchoke_peer(peer_connection& c, bool optimistic = false);
void trigger_unchoke();
void trigger_optimistic_unchoke();
void trigger_unchoke() noexcept;
void trigger_optimistic_unchoke() noexcept;
// used by peer_connection to attach itself to a torrent
// since incoming connections don't know what torrent

View File

@ -5296,16 +5296,14 @@ namespace libtorrent {
return true;
}
void torrent::trigger_unchoke()
void torrent::trigger_unchoke() noexcept
{
m_ses.get_io_service().dispatch(std::bind(
&aux::session_interface::trigger_unchoke, std::ref(m_ses)));
m_ses.trigger_unchoke();
}
void torrent::trigger_optimistic_unchoke()
void torrent::trigger_optimistic_unchoke() noexcept
{
m_ses.get_io_service().dispatch(std::bind(
&aux::session_interface::trigger_optimistic_unchoke, std::ref(m_ses)));
m_ses.trigger_optimistic_unchoke();
}
void torrent::cancel_block(piece_block block)