Merge pull request #556 from arvidn/deprecate-explicit-cache-1.1

deprecate more parts of explicit cache
This commit is contained in:
Arvid Norberg 2016-03-19 11:50:57 -04:00
commit 63747fed22
16 changed files with 41 additions and 33 deletions

View File

@ -198,7 +198,7 @@ void bind_create_torrent()
.def(init<file_storage&>())
.def(init<torrent_info const&>(arg("ti")))
.def(init<file_storage&, int, int, int>((arg("storage"), arg("piece_size") = 0
, arg("pad_file_limit") = -1, arg("flags") = int(libtorrent::create_torrent::optimize))))
, arg("pad_file_limit") = -1, arg("flags") = int(libtorrent::create_torrent::optimize_alignment))))
.def("generate", &create_torrent::generate)
@ -220,7 +220,10 @@ void bind_create_torrent()
;
enum_<create_torrent::flags_t>("create_torrent_flags_t")
#ifndef TORRENT_NO_DEPRECATE
.value("optimize", create_torrent::optimize)
#endif
.value("optimize_alignment", create_torrent::optimize_alignment)
.value("merkle", create_torrent::merkle)
.value("modification_time", create_torrent::modification_time)
.value("symlinks", create_torrent::symlinks)

View File

@ -264,7 +264,7 @@ int main(int argc, char* argv[])
case 'p':
++i;
pad_file_limit = atoi(argv[i]);
flags |= create_torrent::optimize;
flags |= create_torrent::optimize_alignment;
break;
case 's':
++i;

View File

@ -933,7 +933,7 @@ namespace libtorrent
// torrents.
int m_auto_scrape_time_scaler;
#ifndef TORRENT_NO_DEPRECATED
#ifndef TORRENT_NO_DEPRECATE
// the index of the torrent that we'll
// refresh the next time
int m_next_explicit_cache_torrent;

View File

@ -114,7 +114,7 @@ namespace libtorrent
// files, to keep the impact down for clients that don't support
// them.
optimize_alignment = 1,
#ifndef TORRENT_NO_DEPRECATED
#ifndef TORRENT_NO_DEPRECATE
// same as optimize_alignment, for backwards compatibility
optimize = 1,
#endif
@ -158,8 +158,8 @@ namespace libtorrent
// If a ``pad_size_limit`` is specified (other than -1), any file larger than
// the specified number of bytes will be preceeded by a pad file to align it
// with the start of a piece. The pad_file_limit is ignored unless the
// ``optimize`` flag is passed. Typically it doesn't make sense to set this
// any lower than 4kiB.
// ``optimize_alignment`` flag is passed. Typically it doesn't make sense
// to set this any lower than 4kiB.
//
// The overload that takes a ``torrent_info`` object will make a verbatim
// copy of its info dictionary (to preserve the info-hash). The copy of
@ -175,7 +175,8 @@ namespace libtorrent
// eligible files are aligned to. The default is -1, which means the
// piece size of the torrent.
create_torrent(file_storage& fs, int piece_size = 0
, int pad_file_limit = -1, int flags = optimize, int alignment = -1);
, int pad_file_limit = -1, int flags = optimize_alignment
, int alignment = -1);
create_torrent(torrent_info const& ti);
// internal
@ -302,7 +303,7 @@ namespace libtorrent
private:
file_storage& m_files;
// if m_info_dict is initialized, it is
// if m_info_dict is initialized, it is
// used instead of m_files to generate
// the info dictionary
entry m_info_dict;

View File

@ -71,6 +71,8 @@ namespace libtorrent
, std::vector<std::string>& links
, boost::function<void(disk_io_job const*)> const& handler) = 0;
#ifndef TORRENT_NO_DEPRECATE
virtual void async_cache_piece(piece_manager* storage, int piece
, boost::function<void(disk_io_job const*)> const& handler) = 0;
virtual void async_finalize_file(piece_manager*, int file
, boost::function<void(disk_io_job const*)> const& handler
= boost::function<void(disk_io_job const*)>()) = 0;
@ -78,8 +80,6 @@ namespace libtorrent
virtual void async_flush_piece(piece_manager* storage, int piece
, boost::function<void(disk_io_job const*)> const& handler
= boost::function<void(disk_io_job const*)>()) = 0;
virtual void async_cache_piece(piece_manager* storage, int piece
, boost::function<void(disk_io_job const*)> const& handler) = 0;
virtual void async_stop_torrent(piece_manager* storage
, boost::function<void(disk_io_job const*)> const& handler)= 0;
virtual void async_rename_file(piece_manager* storage, int index, std::string const& name

View File

@ -92,8 +92,8 @@ namespace libtorrent
, save_resume_data
, rename_file
, stop_torrent
, cache_piece
#ifndef TORRENT_NO_DEPRECATE
, cache_piece
, finalize_file
#endif
, flush_piece

View File

@ -323,9 +323,9 @@ namespace libtorrent
, boost::function<void(disk_io_job const*)> const& handler);
void async_stop_torrent(piece_manager* storage
, boost::function<void(disk_io_job const*)> const& handler);
#ifndef TORRENT_NO_DEPRECATE
void async_cache_piece(piece_manager* storage, int piece
, boost::function<void(disk_io_job const*)> const& handler);
#ifndef TORRENT_NO_DEPRECATE
void async_finalize_file(piece_manager* storage, int file
, boost::function<void(disk_io_job const*)> const& handler
= boost::function<void(disk_io_job const*)>());
@ -417,8 +417,8 @@ namespace libtorrent
int do_rename_file(disk_io_job* j, jobqueue_t& completed_jobs);
int do_stop_torrent(disk_io_job* j, jobqueue_t& completed_jobs);
int do_read_and_hash(disk_io_job* j, jobqueue_t& completed_jobs);
int do_cache_piece(disk_io_job* j, jobqueue_t& completed_jobs);
#ifndef TORRENT_NO_DEPRECATE
int do_cache_piece(disk_io_job* j, jobqueue_t& completed_jobs);
int do_finalize_file(disk_io_job* j, jobqueue_t& completed_jobs);
#endif
int do_flush_piece(disk_io_job* j, jobqueue_t& completed_jobs);

View File

@ -264,7 +264,7 @@ namespace libtorrent
// reading blocks back from the disk multiple times for popular
// pieces.
use_read_cache,
#ifndef TORRENT_NO_DEPRECATED
#ifndef TORRENT_NO_DEPRECATE
use_write_cache,
#else
deprecated7,
@ -275,7 +275,7 @@ namespace libtorrent
// hash
dont_flush_write_cache,
#ifndef TORRENT_NO_DEPRECATED
#ifndef TORRENT_NO_DEPRECATE
// ``explicit_read_cache`` defaults to 0. If set to something greater
// than 0, the disk read cache will not be evicted by cache misses and
// will explicitly be controlled based on the rarity of pieces. Rare
@ -928,7 +928,7 @@ namespace libtorrent
cache_buffer_chunk_size,
cache_expiry,
#ifndef TORRENT_NO_DEPRECATED
#ifndef TORRENT_NO_DEPRECATE
// ``explicit_cache_interval`` is the number of seconds in between
// each refresh of a part of the explicit read cache. Torrents take
// turns in refreshing and this is the time in between each torrent

View File

@ -676,7 +676,7 @@ namespace libtorrent
void get_peer_info(std::vector<peer_info>& v);
void get_download_queue(std::vector<partial_piece_info>* queue) const;
#ifndef TORRENT_NO_DEPRECATED
#ifndef TORRENT_NO_DEPRECATE
void refresh_explicit_cache(int cache_size);
#endif

View File

@ -203,8 +203,8 @@ const char* const job_action_name[] =
"save_resume_data",
"rename_file",
"stop_torrent",
"cache_piece",
#ifndef TORRENT_NO_DEPRECATE
"cache_piece",
"finalize_file",
#endif
"flush_piece",
@ -218,6 +218,12 @@ const char* const job_action_name[] =
"resolve_links"
};
#if __cplusplus >= 201103L
// make sure the job names array covers all the job IDs
static_assert(sizeof(job_action_name)/sizeof(job_action_name[0])
== disk_io_job::num_job_ids, "disk-job-action and action-name-array mismatch");
#endif
#if TORRENT_USE_ASSERTS
char const* const piece_log_t::job_names[7] =
@ -359,9 +365,6 @@ block_cache::block_cache(int block_size, io_service& ios
, m_send_buffer_blocks(0)
, m_pinned_blocks(0)
{
// make sure the job names array covers all the job IDs
TORRENT_ASSERT(sizeof(job_action_name)/sizeof(job_action_name[0])
== disk_io_job::num_job_ids);
}
// returns:

View File

@ -1040,8 +1040,8 @@ namespace libtorrent
&disk_io_thread::do_save_resume_data,
&disk_io_thread::do_rename_file,
&disk_io_thread::do_stop_torrent,
&disk_io_thread::do_cache_piece,
#ifndef TORRENT_NO_DEPRECATE
&disk_io_thread::do_cache_piece,
&disk_io_thread::do_finalize_file,
#endif
&disk_io_thread::do_flush_piece,
@ -1951,6 +1951,7 @@ namespace libtorrent
add_completed_jobs(completed_jobs);
}
#ifndef TORRENT_NO_DEPRECATE
void disk_io_thread::async_cache_piece(piece_manager* storage, int piece
, boost::function<void(disk_io_job const*)> const& handler)
{
@ -1968,7 +1969,6 @@ namespace libtorrent
add_job(j);
}
#ifndef TORRENT_NO_DEPRECATE
void disk_io_thread::async_finalize_file(piece_manager* storage, int file
, boost::function<void(disk_io_job const*)> const& handler)
{
@ -1985,7 +1985,7 @@ namespace libtorrent
add_job(j);
}
#endif
#endif // TORRENT_NO_DEPRECATE
void disk_io_thread::async_flush_piece(piece_manager* storage, int piece
, boost::function<void(disk_io_job const*)> const& handler)
@ -2618,6 +2618,7 @@ namespace libtorrent
return j->error ? -1 : 0;
}
#ifndef TORRENT_NO_DEPRECATE
int disk_io_thread::do_cache_piece(disk_io_job* j, jobqueue_t& /* completed_jobs */ )
{
INVARIANT_CHECK;
@ -2719,13 +2720,12 @@ namespace libtorrent
return 0;
}
#ifndef TORRENT_NO_DEPRECATE
int disk_io_thread::do_finalize_file(disk_io_job* j, jobqueue_t& /* completed_jobs */)
{
j->storage->get_storage_impl()->finalize_file(j->piece, j->error);
return j->error ? -1 : 0;
}
#endif
#endif // TORRENT_NO_DEPRECATE
namespace {

View File

@ -1013,7 +1013,7 @@ namespace libtorrent
p.set_bool(settings_pack::enable_natpmp, false);
apply_settings(p);
}
#endif // TORRENT_NO_DEPRECATED
#endif // TORRENT_NO_DEPRECATE
int session_handle::add_port_mapping(session::protocol_type t, int external_port, int local_port)
{

View File

@ -393,7 +393,7 @@ namespace aux {
, m_optimistic_unchoke_time_scaler(0)
, m_disconnect_time_scaler(90)
, m_auto_scrape_time_scaler(180)
#ifndef TORRENT_NO_DEPRECATED
#ifndef TORRENT_NO_DEPRECATE
, m_next_explicit_cache_torrent(0)
, m_cache_rotation_timer(0)
#endif
@ -3335,7 +3335,7 @@ retry:
++m_next_suggest_torrent;
}
#ifndef TORRENT_NO_DEPRECATED
#ifndef TORRENT_NO_DEPRECATE
// --------------------------------------------------------------
// refresh explicit disk read cache
// --------------------------------------------------------------

View File

@ -10576,7 +10576,7 @@ namespace libtorrent
update_want_peers();
}
#ifndef TORRENT_NO_DEPRECATED
#ifndef TORRENT_NO_DEPRECATE
// TODO: 2 this should probably be removed
void torrent::refresh_explicit_cache(int cache_size)
{
@ -10675,7 +10675,7 @@ namespace libtorrent
}
}
}
#endif
#endif // TORRENT_NO_DEPRECATE
void torrent::sent_bytes(int bytes_payload, int bytes_protocol)
{

View File

@ -103,7 +103,8 @@ void test_checking(int flags = read_only_files)
, file_sizes, num_files);
add_files(fs, combine_path("tmp1_checking", "test_torrent_dir"));
libtorrent::create_torrent t(fs, piece_size, 0x4000, libtorrent::create_torrent::optimize);
libtorrent::create_torrent t(fs, piece_size, 0x4000
, libtorrent::create_torrent::optimize_alignment);
// calculate the hash for all pieces
set_piece_hashes(t, "tmp1_checking", ec);

View File

@ -410,7 +410,7 @@ void test_remap_files_prio(storage_mode_t storage_mode = storage_mode_sparse)
add_files(fs1, combine_path("tmp1_remap3", "test_torrent_dir"));
libtorrent::create_torrent ct(fs1, piece_size, 0x4000
, libtorrent::create_torrent::optimize);
, libtorrent::create_torrent::optimize_alignment);
// calculate the hash for all pieces
set_piece_hashes(ct, "tmp1_remap3", ec);