diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 7cb079fb4..a82285f4c 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1311,7 +1311,7 @@ int main(int argc, char* argv[]) switch (argv[i][1]) { case 'f': g_log_file = std::fopen(arg, "w+"); break; - case 'k': high_performance_seed(settings); --i; break; + case 'k': settings = high_performance_seed(); --i; break; case 'G': seed_mode = true; --i; break; case 's': save_path = arg; break; case 'U': torrent_upload_limit = atoi(arg) * 1000; break; diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index d987bfe9c..1d4ad5b27 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -216,7 +216,7 @@ namespace libtorrent session_impl(io_service& ios); virtual ~session_impl(); - void start_session(settings_pack const& pack); + void start_session(settings_pack pack); void set_load_function(user_load_function_t fun) { m_user_load_torrent = fun; } diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 35bc877f6..6fc346dc4 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -76,8 +76,16 @@ namespace libtorrent // serving many peers and that doesn't do any downloading. It has a 128 MB // disk cache and has a limit of 400 files in its file pool. It support fast // upload rates by allowing large send buffers. - TORRENT_EXPORT void min_memory_usage(settings_pack& set); - TORRENT_EXPORT void high_performance_seed(settings_pack& set); + TORRENT_EXPORT settings_pack min_memory_usage(); + TORRENT_EXPORT settings_pack high_performance_seed(); +#ifndef TORRENT_NO_DEPRECATE + TORRENT_DEPRECATED + inline void min_memory_usage(settings_pack& set) + { set = min_memory_usage(); } + TORRENT_DEPRECATED + inline void high_performance_seed(settings_pack& set) + { set = high_performance_seed(); } +#endif #ifndef TORRENT_CFG #error TORRENT_CFG is not defined! @@ -215,7 +223,7 @@ namespace libtorrent : session_handle(nullptr) { TORRENT_CFG(); - start(flags, pack, nullptr); + start(flags, std::move(pack), nullptr); } // moveable @@ -245,7 +253,7 @@ namespace libtorrent : session_handle(nullptr) { TORRENT_CFG(); - start(flags, pack, &ios); + start(flags, std::move(pack), &ios); } #ifndef TORRENT_NO_DEPRECATE diff --git a/src/session.cpp b/src/session.cpp index dd172edb4..acae59767 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -38,12 +38,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/session_impl.hpp" #include "libtorrent/aux_/session_call.hpp" -using libtorrent::aux::session_impl; - namespace libtorrent { - void min_memory_usage(settings_pack& set) + settings_pack min_memory_usage() { + settings_pack set; #ifndef TORRENT_NO_DEPRECATE // receive data directly into disk buffers // this yields more system calls to read() and @@ -128,10 +127,12 @@ namespace libtorrent // whole pieces set.set_bool(settings_pack::coalesce_reads, false); set.set_bool(settings_pack::coalesce_writes, false); + return set; } - void high_performance_seed(settings_pack& set) + settings_pack high_performance_seed() { + settings_pack set; // don't throttle TCP, assume there is // plenty of bandwidth set.set_int(settings_pack::mixed_mode_algorithm, settings_pack::prefer_tcp); @@ -246,6 +247,7 @@ namespace libtorrent // the disk cache performs better with the pool allocator set.set_bool(settings_pack::use_disk_cache_pool, true); + return set; } #ifndef TORRENT_CFG @@ -308,7 +310,7 @@ namespace libtorrent ios = m_io_service.get(); } - m_impl = std::make_shared(*ios); + m_impl = std::make_shared(*ios); *static_cast(this) = session_handle(m_impl.get()); #ifndef TORRENT_DISABLE_EXTENSIONS @@ -330,7 +332,7 @@ namespace libtorrent { // start a thread for the message pump m_thread = std::make_shared( - [&]() { m_io_service->run(); }); + [&] { m_io_service->run(); }); } } @@ -341,7 +343,7 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_EXTENSIONS if (empty) return {}; - using wrapper = session_impl::session_plugin_wrapper; + using wrapper = aux::session_impl::session_plugin_wrapper; return { std::make_shared(create_ut_pex_plugin), std::make_shared(create_ut_metadata_plugin), @@ -365,11 +367,11 @@ namespace libtorrent aux::dump_call_profile(); TORRENT_ASSERT(m_impl); - std::shared_ptr ptr = m_impl; + std::shared_ptr ptr = m_impl; // capture the shared_ptr in the dispatched function // to keep the session_impl alive - m_impl->get_io_service().dispatch([=]() { ptr->abort(); }); + m_impl->get_io_service().dispatch([=] { ptr->abort(); }); #if defined TORRENT_ASIO_DEBUGGING int counter = 0; diff --git a/src/session_handle.cpp b/src/session_handle.cpp index 79fc6c7ff..b88e2aa75 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -833,7 +833,7 @@ namespace libtorrent || s.get_int(settings_pack::allowed_enc_level) <= settings_pack::pe_both); - std::shared_ptr copy = std::make_shared(std::move(s)); + auto copy = std::make_shared(std::move(s)); async_call(&session_impl::apply_settings_pack, copy); } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 00139fa33..bc55197d6 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -447,7 +447,7 @@ namespace aux { // io_service thread. // TODO: 2 is there a reason not to move all of this into init()? and just // post it to the io_service? - void session_impl::start_session(settings_pack const& pack) + void session_impl::start_session(settings_pack pack) { if (pack.has_val(settings_pack::alert_mask)) { @@ -520,7 +520,7 @@ namespace aux { } #endif - std::shared_ptr copy = std::make_shared(pack); + auto copy = std::make_shared(std::move(pack)); m_io_service.post(std::bind(&session_impl::init, this, copy)); }