diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-27 15:20:30 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-27 18:22:29 +0200 |
commit | bb80d168af2c5e36903dd61473fdbd3840846d7f (patch) | |
tree | a32bfbca3d4f47b3eb1747d6226030dafc057a7a /include | |
parent | 9aecfa8da5daae017ce3ff21fd6b496fda2a690b (diff) |
Stop download of thumbnail if the thumbnail is no longer visible on the screen
Diffstat (limited to 'include')
-rw-r--r-- | include/AsyncImageLoader.hpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/include/AsyncImageLoader.hpp b/include/AsyncImageLoader.hpp index 77fd5b4..94b225d 100644 --- a/include/AsyncImageLoader.hpp +++ b/include/AsyncImageLoader.hpp @@ -54,6 +54,15 @@ namespace QuickMedia { // Note: this method is not thread-safe void update(); private: + struct Download { + ReadProgram read_program; + int64_t download_start = 0; + Path thumbnail_path; + std::shared_ptr<ThumbnailData> thumbnail_data; + sf::Vector2i resize_target_size; + std::string url; + }; + AsyncImageLoader(); ~AsyncImageLoader(); AsyncImageLoader(AsyncImageLoader &other) = delete; @@ -65,16 +74,9 @@ namespace QuickMedia { // Returns -1 if all threads are busy int get_free_load_index() const; - private: - struct Download { - ReadProgram read_program; - int64_t download_start = 0; - Path thumbnail_path; - std::shared_ptr<ThumbnailData> thumbnail_data; - sf::Vector2i resize_target_size; - std::string url; - }; + void reset_download(Download &download); + private: std::mutex download_mutex; // TODO: Use curl single-threaded multi-download feature instead Download downloads[NUM_IMAGE_LOAD_PARALLEL]; |