From cfb6238ad7fe7dd7d2eca64676437bb871802375 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 18 Feb 2022 17:59:28 +0100 Subject: Faster image loading/thumbnail creation by using multiple threads --- include/AsyncImageLoader.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include/AsyncImageLoader.hpp') diff --git a/include/AsyncImageLoader.hpp b/include/AsyncImageLoader.hpp index 23c2889..c482a3a 100644 --- a/include/AsyncImageLoader.hpp +++ b/include/AsyncImageLoader.hpp @@ -41,6 +41,7 @@ namespace QuickMedia { // One example of why you might not want a symlink is if |thumbnail_path| is a temporary file. bool create_thumbnail(const Path &thumbnail_path, const Path &thumbnail_path_resized, mgl::vec2i resize_target_size, ContentType content_type, bool symlink_if_no_resize); + constexpr int NUM_IMAGE_DOWNLOAD_PARALLEL = 4; constexpr int NUM_IMAGE_LOAD_PARALLEL = 4; class AsyncImageLoader { @@ -85,8 +86,8 @@ namespace QuickMedia { private: std::mutex download_mutex; // TODO: Use curl single-threaded multi-download feature instead - Download downloads[NUM_IMAGE_LOAD_PARALLEL]; - AsyncTask load_thread; + Download downloads[NUM_IMAGE_DOWNLOAD_PARALLEL]; + AsyncTask load_threads[NUM_IMAGE_LOAD_PARALLEL]; MessageQueue image_thumbnail_create_queue; std::unordered_map> thumbnails; size_t counter = 0; -- cgit v1.2.3