turn some more members of session_impl to private

This commit is contained in:
Arvid Norberg 2015-06-03 04:33:20 +00:00
parent 0351326add
commit 4e1e53f066
6 changed files with 60 additions and 66 deletions

View File

@ -64,7 +64,7 @@ void sync_call_handle(Handle& h, boost::function<void(void)> f)
{
bool done = false;
session_impl& ses = (session_impl&) h->session();
ses.m_io_service.dispatch(boost::bind(&aux::fun_wrap
ses.get_io_service().dispatch(boost::bind(&aux::fun_wrap
, boost::ref(done)
, boost::ref(ses.cond)
, boost::ref(ses.mut), f));
@ -77,7 +77,7 @@ Ret sync_call_ret(aux::session_impl& ses, boost::function<Ret(void)> f)
{
bool done = false;
Ret r;
ses.m_io_service.dispatch(boost::bind(&fun_ret<Ret>
ses.get_io_service().dispatch(boost::bind(&fun_ret<Ret>
, boost::ref(r)
, boost::ref(done)
, boost::ref(ses.cond)
@ -92,7 +92,7 @@ void sync_call_ret_handle(Handle& h, Ret& r, boost::function<Ret(void)> f)
{
bool done = false;
session_impl& ses = (session_impl&) h->session();
ses.m_io_service.dispatch(boost::bind(&aux::fun_ret<Ret>
ses.get_io_service().dispatch(boost::bind(&aux::fun_ret<Ret>
, boost::ref(r)
, boost::ref(done)
, boost::ref(ses.cond)

View File

@ -168,10 +168,9 @@ namespace libtorrent
enum { send_buffer_size_impl = 128 };
#ifdef TORRENT_DEBUG
friend class ::libtorrent::peer_connection;
// friend class ::libtorrent::peer_connection;
#endif
friend struct checker_impl;
friend class invariant_access;
friend class libtorrent::invariant_access;
typedef std::set<boost::shared_ptr<peer_connection> > connection_map;
#if TORRENT_HAS_BOOST_UNORDERED
typedef boost::unordered_map<sha1_hash, boost::shared_ptr<torrent> > torrent_map;
@ -598,19 +597,14 @@ namespace libtorrent
libtorrent::utp_socket_manager* utp_socket_manager() { return &m_utp_socket_manager; }
void inc_boost_connections() { ++m_boost_connections; }
private:
#ifndef TORRENT_NO_DEPRECATE
// the time when the next rss feed needs updating
time_point m_next_rss_update;
std::vector<torrent*> m_torrent_lists[num_torrent_lists];
peer_class_pool m_classes;
void init(boost::shared_ptr<settings_pack> pack);
// TODO: 3 fix this. all this should not be public. start by making
// everything that doesn't have to be public private.
public:
void submit_disk_jobs();
// update any rss feeds that need updating and
// recalculate m_next_rss_update
void update_rss_feeds();
#endif
void update_proxy();
void update_i2p_bridge();
@ -625,7 +619,6 @@ namespace libtorrent
void update_network_threads();
void update_cache_buffer_chunk_size();
void update_report_web_seed_downloads();
void trigger_auto_manage();
void update_outgoing_interfaces();
void update_listen_interfaces();
void update_privileged_ports();
@ -639,8 +632,6 @@ namespace libtorrent
void update_count_slow();
void update_peer_fingerprint();
void on_trigger_auto_manage();
void update_socket_buffer_size();
void update_dht_announce_interval();
void update_anonymous_mode();
@ -656,6 +647,20 @@ namespace libtorrent
#endif
void update_alert_mask();
void trigger_auto_manage();
private:
std::vector<torrent*> m_torrent_lists[num_torrent_lists];
peer_class_pool m_classes;
void init(boost::shared_ptr<settings_pack> pack);
void submit_disk_jobs();
void on_trigger_auto_manage();
void on_lsd_peer(tcp::endpoint peer, sha1_hash const& ih);
void setup_socket_buffers(socket_type& s);
@ -968,15 +973,6 @@ namespace libtorrent
// and stopped (only the auto managed ones)
time_point m_last_auto_manage;
#ifndef TORRENT_NO_DEPRECATE
// the time when the next rss feed needs updating
time_point m_next_rss_update;
// update any rss feeds that need updating and
// recalculate m_next_rss_update
void update_rss_feeds();
#endif
// when outgoing_ports is configured, this is the
// port we'll bind the next outgoing socket to
mutable int m_next_port;
@ -1123,8 +1119,6 @@ namespace libtorrent
std::list<boost::shared_ptr<tracker_logger> > m_tracker_loggers;
#endif
private:
// TODO: 2 the throttling of saving resume data could probably be
// factored out into a separate class
void queue_async_resume_data(boost::shared_ptr<torrent> const& t);

View File

@ -348,9 +348,9 @@ void feed::on_feed(error_code const& ec
{
++m_failures;
m_error = ec;
if (m_ses.m_alerts.should_post<rss_alert>())
if (m_ses.alerts().should_post<rss_alert>())
{
m_ses.m_alerts.emplace_alert<rss_alert>(my_handle(), m_settings.url
m_ses.alerts().emplace_alert<rss_alert>(my_handle(), m_settings.url
, rss_alert::state_error, m_error);
}
return;
@ -360,9 +360,9 @@ void feed::on_feed(error_code const& ec
{
++m_failures;
m_error = error_code(parser.status_code(), get_http_category());
if (m_ses.m_alerts.should_post<rss_alert>())
if (m_ses.alerts().should_post<rss_alert>())
{
m_ses.m_alerts.emplace_alert<rss_alert>(my_handle(), m_settings.url
m_ses.alerts().emplace_alert<rss_alert>(my_handle(), m_settings.url
, rss_alert::state_error, m_error);
}
return;
@ -405,9 +405,9 @@ void feed::on_feed(error_code const& ec
#endif
// report that we successfully updated the feed
if (m_ses.m_alerts.should_post<rss_alert>())
if (m_ses.alerts().should_post<rss_alert>())
{
m_ses.m_alerts.emplace_alert<rss_alert>(my_handle(), m_settings.url
m_ses.alerts().emplace_alert<rss_alert>(my_handle(), m_settings.url
, rss_alert::state_updated, error_code());
}
@ -435,7 +435,7 @@ void feed::load_state(bdecode_node const& rd)
{
bdecode_node entry = e.list_at(i);
if (entry.type() != bdecode_node::dict_t) continue;
m_items.push_back(feed_item());
feed_item& item = m_items.back();
item.url = entry.dict_find_string_value("url");
@ -560,8 +560,8 @@ void feed::add_item(feed_item const& item)
if (m_settings.auto_map_handles)
i.handle = torrent_handle(m_ses.find_torrent(i.uuid.empty() ? i.url : i.uuid));
if (m_ses.m_alerts.should_post<rss_item_alert>())
m_ses.m_alerts.emplace_alert<rss_item_alert>(my_handle(), i);
if (m_ses.alerts().should_post<rss_item_alert>())
m_ses.alerts().emplace_alert<rss_item_alert>(my_handle(), i);
if (m_settings.auto_download)
{
@ -605,9 +605,9 @@ int feed::update_feed()
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
if (m_ses.m_alerts.should_post<rss_alert>())
if (m_ses.alerts().should_post<rss_alert>())
{
m_ses.m_alerts.emplace_alert<rss_alert>(my_handle(), m_settings.url
m_ses.alerts().emplace_alert<rss_alert>(my_handle(), m_settings.url
, rss_alert::state_updating, error_code());
}
@ -616,14 +616,14 @@ int feed::update_feed()
#endif
boost::shared_ptr<http_connection> feed(
new http_connection(m_ses.m_io_service
, m_ses.m_host_resolver
new http_connection(m_ses.get_io_service()
, m_ses.get_resolver()
, boost::bind(&feed::on_feed, shared_from_this()
, _1, _2, _3, _4)));
m_updating = true;
feed->get(m_settings.url, seconds(30), 0, 0, 5
, m_ses.m_settings.get_str(settings_pack::user_agent));
, m_ses.settings().get_str(settings_pack::user_agent));
return 60 + m_failures * m_failures * 60;
}
@ -653,13 +653,13 @@ int feed::next_update(time_t now) const
boost::shared_ptr<feed> f = m_feed_ptr.lock(); \
if (!f) return; \
aux::session_impl& ses = f->session(); \
ses.m_io_service.post(boost::bind(&feed:: x, f))
ses.get_io_service().post(boost::bind(&feed:: x, f))
#define TORRENT_ASYNC_CALL1(x, a1) \
boost::shared_ptr<feed> f = m_feed_ptr.lock(); \
if (!f) return; \
aux::session_impl& ses = f->session(); \
ses.m_io_service.post(boost::bind(&feed:: x, f, a1))
ses.get_io_service().post(boost::bind(&feed:: x, f, a1))
#define TORRENT_SYNC_CALL1(x, a1) \
boost::shared_ptr<feed> f = m_feed_ptr.lock(); \

View File

@ -336,16 +336,16 @@ namespace libtorrent
#endif
#define TORRENT_ASYNC_CALL(x) \
m_impl->m_io_service.dispatch(boost::bind(&session_impl:: x, m_impl.get()))
m_impl->get_io_service().dispatch(boost::bind(&session_impl:: x, m_impl.get()))
#define TORRENT_ASYNC_CALL1(x, a1) \
m_impl->m_io_service.dispatch(boost::bind(&session_impl:: x, m_impl.get(), a1))
m_impl->get_io_service().dispatch(boost::bind(&session_impl:: x, m_impl.get(), a1))
#define TORRENT_ASYNC_CALL2(x, a1, a2) \
m_impl->m_io_service.dispatch(boost::bind(&session_impl:: x, m_impl.get(), a1, a2))
m_impl->get_io_service().dispatch(boost::bind(&session_impl:: x, m_impl.get(), a1, a2))
#define TORRENT_ASYNC_CALL3(x, a1, a2, a3) \
m_impl->m_io_service.dispatch(boost::bind(&session_impl:: x, m_impl.get(), a1, a2, a3))
m_impl->get_io_service().dispatch(boost::bind(&session_impl:: x, m_impl.get(), a1, a2, a3))
#define TORRENT_SYNC_CALL(x) \
aux::sync_call(*m_impl, boost::function<void(void)>(boost::bind(&session_impl:: x, m_impl.get())))
@ -552,7 +552,7 @@ namespace libtorrent
boost::shared_ptr<ip_filter> copy = boost::make_shared<ip_filter>(f);
TORRENT_ASYNC_CALL1(set_ip_filter, copy);
}
ip_filter session::get_ip_filter() const
{
return TORRENT_SYNC_CALL_RET(ip_filter, get_ip_filter);
@ -571,7 +571,7 @@ namespace libtorrent
apply_settings(p);
}
#endif
peer_id session::id() const
{
return TORRENT_SYNC_CALL_RET(peer_id, get_peer_id);
@ -579,7 +579,7 @@ namespace libtorrent
io_service& session::get_io_service()
{
return m_impl->m_io_service;
return m_impl->get_io_service();
}
void session::set_key(int key)
@ -804,7 +804,7 @@ namespace libtorrent
else
flags = session::disk_cache_no_pieces;
}
m_impl->m_disk_thread.get_cache_info(ret, flags & session::disk_cache_no_pieces, st);
m_impl->disk_thread().get_cache_info(ret, flags & session::disk_cache_no_pieces, st);
}
#ifndef TORRENT_NO_DEPRECATE
@ -1156,7 +1156,7 @@ namespace libtorrent
void session::set_alert_dispatch(boost::function<void(std::auto_ptr<alert>)> const& fun)
{
m_impl->m_alerts.set_dispatch_function(fun);
m_impl->alerts().set_dispatch_function(fun);
}
#endif // TORRENT_NO_DEPRECATE
@ -1173,7 +1173,7 @@ namespace libtorrent
void session::set_alert_notify(boost::function<void()> const& fun)
{
m_impl->m_alerts.set_notify_function(fun);
m_impl->alerts().set_notify_function(fun);
}
#ifndef TORRENT_NO_DEPRECATE

View File

@ -89,7 +89,7 @@ void torrent_wait(bool& done, aux::session_impl& ses)
void sync_call(aux::session_impl& ses, boost::function<void(void)> f)
{
bool done = false;
ses.m_io_service.dispatch(boost::bind(&fun_wrap
ses.get_io_service().dispatch(boost::bind(&fun_wrap
, boost::ref(done)
, boost::ref(ses.cond)
, boost::ref(ses.mut)

View File

@ -146,31 +146,31 @@ namespace libtorrent
boost::shared_ptr<torrent> t = m_torrent.lock(); \
if (!t) return; \
session_impl& ses = (session_impl&) t->session(); \
ses.m_io_service.dispatch(boost::bind(&torrent:: x, t))
ses.get_io_service().dispatch(boost::bind(&torrent:: x, t))
#define TORRENT_ASYNC_CALL1(x, a1) \
boost::shared_ptr<torrent> t = m_torrent.lock(); \
if (!t) return; \
session_impl& ses = (session_impl&) t->session(); \
ses.m_io_service.dispatch(boost::bind(&torrent:: x, t, a1))
ses.get_io_service().dispatch(boost::bind(&torrent:: x, t, a1))
#define TORRENT_ASYNC_CALL2(x, a1, a2) \
boost::shared_ptr<torrent> t = m_torrent.lock(); \
if (!t) return; \
session_impl& ses = (session_impl&) t->session(); \
ses.m_io_service.dispatch(boost::bind(&torrent:: x, t, a1, a2))
ses.get_io_service().dispatch(boost::bind(&torrent:: x, t, a1, a2))
#define TORRENT_ASYNC_CALL3(x, a1, a2, a3) \
boost::shared_ptr<torrent> t = m_torrent.lock(); \
if (!t) return; \
session_impl& ses = (session_impl&) t->session(); \
ses.m_io_service.dispatch(boost::bind(&torrent:: x, t, a1, a2, a3))
ses.get_io_service().dispatch(boost::bind(&torrent:: x, t, a1, a2, a3))
#define TORRENT_ASYNC_CALL4(x, a1, a2, a3, a4) \
boost::shared_ptr<torrent> t = m_torrent.lock(); \
if (!t) return; \
session_impl& ses = (session_impl&) t->session(); \
ses.m_io_service.dispatch(boost::bind(&torrent:: x, t, a1, a2, a3, a4))
ses.get_io_service().dispatch(boost::bind(&torrent:: x, t, a1, a2, a3, a4))
#define TORRENT_SYNC_CALL(x) \
boost::shared_ptr<torrent> t = m_torrent.lock(); \
@ -719,7 +719,7 @@ namespace libtorrent
bool done = false;
session_impl& ses = (session_impl&) t->session();
storage_error ec;
ses.m_io_service.dispatch(boost::bind(&aux::fun_wrap, boost::ref(done), boost::ref(ses.cond)
ses.get_io_service().dispatch(boost::bind(&aux::fun_wrap, boost::ref(done), boost::ref(ses.cond)
, boost::ref(ses.mut), boost::function<void(void)>(boost::bind(
&piece_manager::write_resume_data, &t->storage(), boost::ref(ret), boost::ref(ec)))));
t.reset();
@ -776,7 +776,7 @@ namespace libtorrent
boost::shared_ptr<torrent> t = m_torrent.lock();
if (!t || !t->has_storage()) return;
session_impl& ses = (session_impl&) t->session();
ses.m_disk_thread.files().get_status(&status, &t->storage());
ses.disk_thread().files().get_status(&status, &t->storage());
}
void torrent_handle::scrape_tracker() const