renamed some torrent check queue related functions to be more descriptive

This commit is contained in:
Arvid Norberg 2010-01-17 21:42:14 +00:00
parent 3c364731e8
commit d959331c1e
3 changed files with 13 additions and 6 deletions

View File

@ -232,8 +232,8 @@ namespace libtorrent
std::vector<torrent_handle> get_torrents();
void check_torrent(boost::shared_ptr<torrent> const& t);
void done_checking(boost::shared_ptr<torrent> const& t);
void queue_check_torrent(boost::shared_ptr<torrent> const& t);
void dequeue_check_torrent(boost::shared_ptr<torrent> const& t);
void set_alert_mask(int m);
size_t set_alert_queue_size_limit(size_t queue_size_limit_);
@ -496,6 +496,8 @@ namespace libtorrent
tracker_manager m_tracker_manager;
torrent_map m_torrents;
typedef std::list<boost::shared_ptr<torrent> > check_queue_t;
// this has all torrents that wants to be checked in it
check_queue_t m_queued_for_checking;
// this maps sockets to their peer_connection

View File

@ -2634,7 +2634,7 @@ namespace aux {
return torrent_handle(torrent_ptr);
}
void session_impl::check_torrent(boost::shared_ptr<torrent> const& t)
void session_impl::queue_check_torrent(boost::shared_ptr<torrent> const& t)
{
if (m_abort) return;
TORRENT_ASSERT(t->should_check_files());
@ -2646,11 +2646,14 @@ namespace aux {
m_queued_for_checking.push_back(t);
}
void session_impl::done_checking(boost::shared_ptr<torrent> const& t)
void session_impl::dequeue_check_torrent(boost::shared_ptr<torrent> const& t)
{
INVARIANT_CHECK;
TORRENT_ASSERT(t->state() == torrent_status::checking_files
|| t->state() == torrent_status::queued_for_checking);
if (m_queued_for_checking.empty()) return;
boost::shared_ptr<torrent> next_check = *m_queued_for_checking.begin();
check_queue_t::iterator done = m_queued_for_checking.end();
for (check_queue_t::iterator i = m_queued_for_checking.begin()
@ -2662,10 +2665,12 @@ namespace aux {
next_check = *i;
}
// only start a new one if we removed the one that is checking
TORRENT_ASSERT(done != m_queued_for_checking.end());
if (done == m_queued_for_checking.end()) return;
if (next_check != t && t->state() == torrent_status::checking_files)
next_check->start_checking();
m_queued_for_checking.erase(done);
}

View File

@ -1014,14 +1014,14 @@ namespace libtorrent
{
if (m_queued_for_checking) return;
m_queued_for_checking = true;
m_ses.check_torrent(shared_from_this());
m_ses.queue_check_torrent(shared_from_this());
}
void torrent::dequeue_torrent_check()
{
if (!m_queued_for_checking) return;
m_queued_for_checking = false;
m_ses.done_checking(shared_from_this());
m_ses.dequeue_check_torrent(shared_from_this());
}
void torrent::force_recheck()