diff --git a/bindings/python/src/extensions.cpp b/bindings/python/src/extensions.cpp index 1d24f8c99..05c67f047 100644 --- a/bindings/python/src/extensions.cpp +++ b/bindings/python/src/extensions.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index c307ce5a9..0b87c211a 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -159,6 +159,18 @@ namespace return s.load_country_db(file.c_str()); } #endif + + entry save_state(session const& s) + { + entry e; + s.save_state(e); + return e; + } + + void load_state(session& s, entry const& e) + { + s.load_state(e); + } } // namespace unnamed @@ -316,8 +328,8 @@ void bind_session() .def("load_asnum_db", &load_asnum_db) .def("load_country_db", &load_country_db) #endif - .def("load_state", allow_threads(&session::load_state)) - .def("state", allow_threads(&session::state)) + .def("load_state", &load_state) + .def("save_state", &save_state) #ifndef TORRENT_NO_DEPRECATE .def("set_severity_level", allow_threads(&session::set_severity_level)) #endif diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index bde1dda0a..80d4fa0ae 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "gil.hpp" @@ -274,11 +275,6 @@ void add_piece(torrent_handle& th, int piece, char const *data, int flags) th.add_piece(piece, data, flags); } -void set_piece_deadline(torrent_handle const& th, int index, int deadline_ms, int flags) -{ - th.set_piece_deadline(index, milliseconds(deadline_ms), flags); -} - void bind_torrent_handle() { void (torrent_handle::*force_reannounce0)() const = &torrent_handle::force_reannounce; @@ -342,7 +338,7 @@ void bind_torrent_handle() #endif .def("add_piece", add_piece) .def("read_piece", _(&torrent_handle::read_piece)) - .def("set_piece_deadline", &set_piece_deadline + .def("set_piece_deadline", _(&torrent_handle::set_piece_deadline) , (arg("index"), arg("deadline"), arg("flags") = 0)) .def("piece_availability", &piece_availability) .def("piece_priority", _(piece_priority0)) diff --git a/docs/manual.rst b/docs/manual.rst index 557d8cb01..fa10754d9 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -1964,7 +1964,7 @@ Its declaration looks like this:: bool resolve_countries() const; enum deadline_flags { alert_when_available = 1 }; - void set_piece_deadline(int index, time_duration deadline, int flags = 0) const; + void set_piece_deadline(int index, int deadline, int flags = 0) const; void piece_availability(std::vector& avail) const; void piece_priority(int index, int priority) const; @@ -2021,7 +2021,7 @@ set_piece_deadline() :: enum deadline_flags { alert_when_available = 1 }; - void set_piece_deadline(int index, time_duration deadline, int flags = 0) const; + void set_piece_deadline(int index, int deadline, int flags = 0) const; This function sets or resets the deadline associated with a specific piece index (``index``). libtorrent will attempt to download this entire piece before @@ -2038,8 +2038,7 @@ If the piece is already downloaded when this call is made, nothing happens, unle the ``alert_when_available`` flag is set, in which case it will do the same thing as calling `read_piece()`_ for ``index``. -In the python binding for this function, the ``deadline`` is the number of milliseconds -as an integer. +``deadline`` is the number of milliseconds until this piece should be completed. piece_availability() diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index a1513ee12..4a1baf55e 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -278,7 +278,7 @@ namespace libtorrent void prioritize_files(std::vector const& files); void file_priorities(std::vector&) const; - void set_piece_deadline(int piece, time_duration t, int flags); + void set_piece_deadline(int piece, int t, int flags); void update_piece_priorities(); torrent_status status() const; diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index f15307790..97a1c2bbf 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -394,7 +394,7 @@ namespace libtorrent void get_download_queue(std::vector& queue) const; enum deadline_flags { alert_when_available = 1 }; - void set_piece_deadline(int index, time_duration deadline, int flags = 0) const; + void set_piece_deadline(int index, int deadline, int flags = 0) const; void set_priority(int prio) const; diff --git a/src/torrent.cpp b/src/torrent.cpp index 5dd349127..ef4ad1dc9 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -2402,9 +2402,9 @@ namespace libtorrent return m_username + ":" + m_password; } - void torrent::set_piece_deadline(int piece, time_duration t, int flags) + void torrent::set_piece_deadline(int piece, int t, int flags) { - ptime deadline = time_now() + t; + ptime deadline = time_now() + milliseconds(t); if (is_seed() || m_picker->have_piece(piece)) { diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 9b245840a..3e0842f9b 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -731,7 +731,7 @@ namespace libtorrent TORRENT_FORWARD(get_download_queue(queue)); } - void torrent_handle::set_piece_deadline(int index, time_duration deadline, int flags) const + void torrent_handle::set_piece_deadline(int index, int deadline, int flags) const { INVARIANT_CHECK; TORRENT_FORWARD(set_piece_deadline(index, deadline, flags));