From 97e9fcb00af17d0fd1220ce2a5b4f264bf83e8cf Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 24 Nov 2020 15:12:49 +0100 Subject: Make async image loader static to reduce number of process threads when using multiple instances --- include/AsyncImageLoader.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include/AsyncImageLoader.hpp') diff --git a/include/AsyncImageLoader.hpp b/include/AsyncImageLoader.hpp index c1c2e11..5de9215 100644 --- a/include/AsyncImageLoader.hpp +++ b/include/AsyncImageLoader.hpp @@ -29,14 +29,18 @@ namespace QuickMedia { class AsyncImageLoader { public: - AsyncImageLoader(); - ~AsyncImageLoader(); + static AsyncImageLoader& get_instance(); // Returns false if the image loader is already loading an image. In that case, this function should be called again later. // set |resize_target_size| to {0, 0} to disable resizing. // |thumbnail_data.loading_state| has to be LoadingState::NOT_LOADED when calling this! // Note: this method is not thread-safe void load_thumbnail(const std::string &url, bool local, sf::Vector2i resize_target_size, bool use_tor, std::shared_ptr thumbnail_data); private: + AsyncImageLoader(); + ~AsyncImageLoader(); + AsyncImageLoader(AsyncImageLoader &other) = delete; + AsyncImageLoader& operator=(AsyncImageLoader &other) = delete; + struct ThumbnailLoadData { Path path; Path thumbnail_path; -- cgit v1.2.3