initial support for queuing
This commit is contained in:
@@ -198,25 +198,7 @@ namespace libtorrent
|
||||
, const char* net_interface = 0);
|
||||
bool is_listening() const;
|
||||
|
||||
torrent_handle add_torrent(
|
||||
boost::intrusive_ptr<torrent_info> ti
|
||||
, fs::path const& save_path
|
||||
, entry const& resume_data
|
||||
, storage_mode_t storage_mode
|
||||
, storage_constructor_type sc
|
||||
, bool paused
|
||||
, void* userdata);
|
||||
|
||||
torrent_handle add_torrent(
|
||||
char const* tracker_url
|
||||
, sha1_hash const& info_hash
|
||||
, char const* name
|
||||
, fs::path const& save_path
|
||||
, entry const& resume_data
|
||||
, storage_mode_t storage_mode
|
||||
, storage_constructor_type sc
|
||||
, bool paused
|
||||
, void* userdata);
|
||||
torrent_handle add_torrent(add_torrent_params const&);
|
||||
|
||||
void remove_torrent(torrent_handle const& h, int options);
|
||||
|
||||
@@ -491,6 +473,10 @@ namespace libtorrent
|
||||
// recomputed.
|
||||
int m_unchoke_time_scaler;
|
||||
|
||||
// this is used to decide when to recalculate which
|
||||
// torrents to keep queued and which to activate
|
||||
int m_auto_manage_time_scaler;
|
||||
|
||||
// works like unchoke_time_scaler but it
|
||||
// is only decresed when the unchoke set
|
||||
// is recomputed, and when it reaches zero,
|
||||
@@ -513,6 +499,10 @@ namespace libtorrent
|
||||
bool m_incoming_connection;
|
||||
|
||||
void second_tick(asio::error_code const& e);
|
||||
void recalculate_auto_managed_torrents();
|
||||
void recalculate_unchoke_slots(int congested_torrents
|
||||
, int uncongested_torrents);
|
||||
|
||||
ptime m_last_tick;
|
||||
|
||||
// when outgoing_ports is configured, this is the
|
||||
@@ -532,6 +522,10 @@ namespace libtorrent
|
||||
// but for the udp port used by the DHT.
|
||||
int m_external_udp_port;
|
||||
|
||||
// the sequence number to assign to the
|
||||
// next torrent that's added
|
||||
int m_torrent_sequence;
|
||||
|
||||
udp_socket m_dht_socket;
|
||||
|
||||
void on_receive_udp(asio::error_code const& e
|
||||
|
@@ -62,6 +62,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "libtorrent/fingerprint.hpp"
|
||||
#include "libtorrent/time.hpp"
|
||||
#include "libtorrent/disk_io_thread.hpp"
|
||||
#include "libtorrent/peer_id.hpp"
|
||||
|
||||
#include "libtorrent/storage.hpp"
|
||||
|
||||
@@ -120,6 +121,34 @@ namespace libtorrent
|
||||
boost::shared_ptr<aux::session_impl> m_impl;
|
||||
};
|
||||
|
||||
struct add_torrent_params
|
||||
{
|
||||
add_torrent_params(storage_constructor_type sc = default_storage_constructor)
|
||||
: tracker_url(0)
|
||||
, name(0)
|
||||
, resume_data(0)
|
||||
, storage_mode(storage_mode_sparse)
|
||||
, paused(true)
|
||||
, auto_managed(true)
|
||||
, duplicate_is_error(false)
|
||||
, storage(sc)
|
||||
, userdata(0)
|
||||
{}
|
||||
|
||||
boost::intrusive_ptr<torrent_info> ti;
|
||||
char const* tracker_url;
|
||||
sha1_hash info_hash;
|
||||
char const* name;
|
||||
fs::path save_path;
|
||||
entry const* resume_data;
|
||||
storage_mode_t storage_mode;
|
||||
bool paused;
|
||||
bool auto_managed;
|
||||
bool duplicate_is_error;
|
||||
storage_constructor_type storage;
|
||||
void* userdata;
|
||||
};
|
||||
|
||||
class TORRENT_EXPORT session: public boost::noncopyable, aux::eh_initializer
|
||||
{
|
||||
public:
|
||||
@@ -148,6 +177,9 @@ namespace libtorrent
|
||||
torrent_handle find_torrent(sha1_hash const& info_hash) const;
|
||||
|
||||
// all torrent_handles must be destructed before the session is destructed!
|
||||
torrent_handle add_torrent(add_torrent_params const& params);
|
||||
|
||||
// deprecated in 0.14
|
||||
torrent_handle add_torrent(
|
||||
torrent_info const& ti
|
||||
, fs::path const& save_path
|
||||
@@ -156,6 +188,7 @@ namespace libtorrent
|
||||
, bool paused = false
|
||||
, storage_constructor_type sc = default_storage_constructor) TORRENT_DEPRECATED;
|
||||
|
||||
// deprecated in 0.14
|
||||
torrent_handle add_torrent(
|
||||
boost::intrusive_ptr<torrent_info> ti
|
||||
, fs::path const& save_path
|
||||
@@ -163,8 +196,9 @@ namespace libtorrent
|
||||
, storage_mode_t storage_mode = storage_mode_sparse
|
||||
, bool paused = false
|
||||
, storage_constructor_type sc = default_storage_constructor
|
||||
, void* userdata = 0);
|
||||
, void* userdata = 0) TORRENT_DEPRECATED;
|
||||
|
||||
// deprecated in 0.14
|
||||
torrent_handle add_torrent(
|
||||
char const* tracker_url
|
||||
, sha1_hash const& info_hash
|
||||
@@ -174,7 +208,7 @@ namespace libtorrent
|
||||
, storage_mode_t storage_mode = storage_mode_sparse
|
||||
, bool paused = false
|
||||
, storage_constructor_type sc = default_storage_constructor
|
||||
, void* userdata = 0);
|
||||
, void* userdata = 0) TORRENT_DEPRECATED;
|
||||
|
||||
session_proxy abort() { return session_proxy(m_impl); }
|
||||
|
||||
|
@@ -128,6 +128,12 @@ namespace libtorrent
|
||||
, cache_expiry(60)
|
||||
, outgoing_ports(0,0)
|
||||
, peer_tos(0)
|
||||
, active_downloads(8)
|
||||
, active_seeds(5)
|
||||
, auto_manage_interval(30)
|
||||
, share_ratio_limit(2.f)
|
||||
, seed_time_ratio_limit(7.f)
|
||||
, seed_time_limit(24 * 60 * 60) // 24 hours
|
||||
{}
|
||||
|
||||
// this is the user agent that will be sent to the tracker
|
||||
@@ -347,8 +353,31 @@ namespace libtorrent
|
||||
// http://qbone.internet2.edu/qbss/
|
||||
// For unmarked packets, set to 0
|
||||
char peer_tos;
|
||||
};
|
||||
|
||||
// for auto managed torrents, these are the limits
|
||||
// they are subject to. If there are too many torrents
|
||||
// some of the auto managed ones will be paused until
|
||||
// some slots free up.
|
||||
int active_downloads;
|
||||
int active_seeds;
|
||||
|
||||
// the number of seconds in between recalculating which
|
||||
// torrents to activate and which ones to queue
|
||||
int auto_manage_interval;
|
||||
|
||||
// when a seeding torrent reaches eaither the share ratio
|
||||
// (bytes up / bytes down) or the seed time ratio
|
||||
// (seconds as seed / seconds as downloader) or the seed
|
||||
// time limit (seconds as seed) it is considered
|
||||
// done, and it will leave room for other torrents
|
||||
// the default value for share ratio is 2
|
||||
// the default seed time ratio is 7, because that's a common
|
||||
// asymmetry ratio on connections
|
||||
float share_ratio_limit;
|
||||
float seed_time_ratio_limit;
|
||||
int seed_time_limit;
|
||||
};
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
struct dht_settings
|
||||
{
|
||||
|
@@ -105,7 +105,9 @@ namespace libtorrent
|
||||
, int block_size
|
||||
, storage_constructor_type sc
|
||||
, bool paused
|
||||
, entry const& resume_data);
|
||||
, entry const* resume_data
|
||||
, int seq
|
||||
, bool auto_managed);
|
||||
|
||||
// used with metadata-less torrents
|
||||
// (the metadata is downloaded from the peers)
|
||||
@@ -120,7 +122,9 @@ namespace libtorrent
|
||||
, int block_size
|
||||
, storage_constructor_type sc
|
||||
, bool paused
|
||||
, entry const& resume_data);
|
||||
, entry const* resume_data
|
||||
, int seq
|
||||
, bool auto_managed);
|
||||
|
||||
~torrent();
|
||||
|
||||
@@ -147,6 +151,9 @@ namespace libtorrent
|
||||
void files_checked();
|
||||
void start_checking();
|
||||
|
||||
float seed_cycles(session_settings const& s) const;
|
||||
int seed_cycles_int(session_settings const& s) const { return int(seed_cycles(s)); }
|
||||
|
||||
storage_mode_t storage_mode() const { return m_storage_mode; }
|
||||
// this will flag the torrent as aborted. The main
|
||||
// loop in session_impl will check for this state
|
||||
@@ -180,6 +187,9 @@ namespace libtorrent
|
||||
bool is_paused() const { return m_paused; }
|
||||
void save_resume_data();
|
||||
|
||||
bool is_auto_managed() const { return m_auto_managed; }
|
||||
void auto_managed(bool a);
|
||||
|
||||
void delete_files();
|
||||
|
||||
// ============ start deprecation =============
|
||||
@@ -562,6 +572,8 @@ namespace libtorrent
|
||||
// a return value of false indicates an error
|
||||
bool set_metadata(entry const& metadata, std::string& error);
|
||||
|
||||
int sequence_number() const { return m_sequence_number; }
|
||||
|
||||
private:
|
||||
|
||||
void on_files_deleted(int ret, disk_io_job const& j);
|
||||
@@ -593,6 +605,13 @@ namespace libtorrent
|
||||
// paused to the time should_request() is called
|
||||
bool m_just_paused;
|
||||
|
||||
// if this is true, libtorrent may pause and resume
|
||||
// this torrent depending on queuing rules. Torrents
|
||||
// started with auto_managed flag set may be added in
|
||||
// a paused state in case there are no available
|
||||
// slots.
|
||||
bool m_auto_managed;
|
||||
|
||||
tracker_request::event_t m_event;
|
||||
|
||||
void parse_response(const entry& e, std::vector<peer_entry>& peer_list);
|
||||
|
@@ -118,6 +118,7 @@ namespace libtorrent
|
||||
, all_time_download(0)
|
||||
, active_time(0)
|
||||
, seeding_time(0)
|
||||
, seed_cycles(0.f)
|
||||
{}
|
||||
|
||||
enum state_t
|
||||
@@ -255,6 +256,8 @@ namespace libtorrent
|
||||
// from resume data
|
||||
int active_time;
|
||||
int seeding_time;
|
||||
|
||||
float seed_cycles;
|
||||
};
|
||||
|
||||
struct TORRENT_EXPORT block_info
|
||||
@@ -332,6 +335,9 @@ namespace libtorrent
|
||||
void resume() const;
|
||||
void save_resume_data() const;
|
||||
|
||||
bool is_auto_managed() const;
|
||||
void auto_managed(bool m) const;
|
||||
|
||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
void resolve_countries(bool r);
|
||||
bool resolve_countries() const;
|
||||
@@ -342,6 +348,7 @@ namespace libtorrent
|
||||
|
||||
// ================ start deprecation ============
|
||||
|
||||
// deprecated in 0.13
|
||||
// marks the piece with the given index as filtered
|
||||
// it will not be downloaded
|
||||
void filter_piece(int index, bool filter) const TORRENT_DEPRECATED;
|
||||
@@ -370,6 +377,7 @@ namespace libtorrent
|
||||
// to.
|
||||
void use_interface(const char* net_interface) const;
|
||||
|
||||
// deprecated in 0.14
|
||||
// use save_resume_data() instead. It is async. and
|
||||
// will return the resume data in an alert
|
||||
entry write_resume_data() const TORRENT_DEPRECATED;
|
||||
|
Reference in New Issue
Block a user