mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-11 04:32:30 +00:00
Session saving of resume data is added to a pre-queue.
This commit is contained in:
@@ -37,8 +37,12 @@ public:
|
||||
typedef std::unique_ptr<std::stringstream> stream_ptr;
|
||||
|
||||
// TODO: This should depend on max open sockets / be configurable.
|
||||
constexpr static int max_concurrent_saves = 16;
|
||||
constexpr static int max_cleanup_saves = 64;
|
||||
|
||||
// TODO: max_concurrent_requests should be checked before something, review.
|
||||
|
||||
constexpr static int max_concurrent_requests = 16;
|
||||
constexpr static int max_concurrent_saves = 16;
|
||||
constexpr static int max_cleanup_saves = 64;
|
||||
|
||||
SessionManager(torrent::utils::Thread* thread);
|
||||
~SessionManager();
|
||||
@@ -54,8 +58,8 @@ public:
|
||||
bool use_lock() const;
|
||||
void set_use_lock(bool use_lock);
|
||||
|
||||
void save_full_download(core::Download* download) { save_download(download, false); }
|
||||
void save_resume_download(core::Download* download) { save_download(download, true); }
|
||||
void save_full_download(core::Download* download);
|
||||
void save_resume_download(core::Download* download);
|
||||
void remove_download(core::Download* download);
|
||||
|
||||
protected:
|
||||
@@ -68,7 +72,9 @@ protected:
|
||||
void cleanup();
|
||||
|
||||
private:
|
||||
void process_pending_resume_builds();
|
||||
void process_save_request();
|
||||
void process_save_request_with_pending_callback();
|
||||
void process_next_save_request_unsafe();
|
||||
void process_finished_saves();
|
||||
|
||||
@@ -77,10 +83,8 @@ private:
|
||||
// Requires a higher number of open sockets, and should only be used during shutdown.
|
||||
void flush_all_and_wait_unsafe(std::unique_lock<std::mutex>& lock);
|
||||
|
||||
bool remove_save_request_unsafe(core::Download* download, std::unique_lock<std::mutex>& lock);
|
||||
|
||||
void save_download_unsafe(const SaveRequest& request);
|
||||
bool save_download_stream_unsafe(const std::string& path, const std::unique_ptr<std::stringstream>& stream);
|
||||
bool remove_or_replace_unsafe(SaveRequest& download);
|
||||
bool remove_completely_unsafe(core::Download* download, std::unique_lock<std::mutex>& lock);
|
||||
|
||||
torrent::utils::Thread* m_thread;
|
||||
|
||||
@@ -94,14 +98,16 @@ private:
|
||||
|
||||
typedef std::pair<std::future<void>, SaveRequest> ProcessingSave;
|
||||
|
||||
// TODO: Add deque of DownloadStorers requests that have yet to build streams.
|
||||
|
||||
std::deque<SaveRequest> m_save_requests;
|
||||
std::list<ProcessingSave> m_processing_saves;
|
||||
std::condition_variable m_finished_condition;
|
||||
std::vector<ProcessingSave> m_finished_saves;
|
||||
|
||||
std::unique_ptr<utils::Lockfile> m_lockfile;
|
||||
|
||||
// Pending builds are only ever locked by main thread.
|
||||
std::mutex m_pending_builds_mutex;
|
||||
std::deque<core::Download*> m_pending_builds;
|
||||
};
|
||||
|
||||
inline bool SessionManager::is_used() const { return !m_path.empty(); }
|
||||
|
||||
Reference in New Issue
Block a user