initialize torrent object in libtorrent thread instead of in calling thread

This commit is contained in:
Arvid Norberg 2008-11-10 02:33:39 +00:00
parent 18d269dd62
commit 4abd27b40e
2 changed files with 16 additions and 1 deletions

View File

@ -208,6 +208,7 @@ namespace libtorrent
std::vector<torrent_handle> get_torrents(); std::vector<torrent_handle> get_torrents();
void start_torrent(boost::weak_ptr<torrent> wt);
void check_torrent(boost::shared_ptr<torrent> const& t); void check_torrent(boost::shared_ptr<torrent> const& t);
void done_checking(boost::shared_ptr<torrent> const& t); void done_checking(boost::shared_ptr<torrent> const& t);

View File

@ -1834,7 +1834,7 @@ namespace aux {
, params.storage, params.paused, params.resume_data , params.storage, params.paused, params.resume_data
, queue_pos, params.auto_managed)); , queue_pos, params.auto_managed));
} }
torrent_ptr->start(); m_io_service.post(bind(&session_impl::start_torrent, this, boost::weak_ptr<torrent>(torrent_ptr)));
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
for (extension_list_t::iterator i = m_extensions.begin() for (extension_list_t::iterator i = m_extensions.begin()
@ -1878,6 +1878,20 @@ namespace aux {
m_queued_for_checking.push_back(t); m_queued_for_checking.push_back(t);
} }
void session_impl::start_torrent(boost::weak_ptr<torrent> wt)
{
boost::shared_ptr<torrent> t = wt.lock();
if (!t) return;
mutex_t::scoped_lock l(m_mutex);
INVARIANT_CHECK;
if (t->is_aborted()) return;
t->start();
}
void session_impl::done_checking(boost::shared_ptr<torrent> const& t) void session_impl::done_checking(boost::shared_ptr<torrent> const& t)
{ {
if (m_queued_for_checking.empty()) return; if (m_queued_for_checking.empty()) return;