From bbe36a8246041544d6ebe420dfa1b695b6c74521 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sat, 3 Oct 2020 18:49:22 -0400 Subject: maybe slightly better image loading maybe hopefully --- imgmanager.hpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'imgmanager.hpp') diff --git a/imgmanager.hpp b/imgmanager.hpp index 9001500..800d6a2 100644 --- a/imgmanager.hpp +++ b/imgmanager.hpp @@ -2,17 +2,30 @@ #include #include #include +#include #include #include "filecache.hpp" class ImageManager { public: + ImageManager(); + + using callback_type = std::function)>; + Cache &GetCache(); - void LoadFromURL(std::string url, std::function)> cb); + void LoadFromURL(std::string url, callback_type cb); Glib::RefPtr GetFromURLIfCached(std::string url); Glib::RefPtr GetPlaceholder(int size); private: + Glib::RefPtr ReadFileToPixbuf(std::string path); + + mutable std::mutex m_load_mutex; + void RunCallbacks(); + Glib::Dispatcher m_cb_dispatcher; + mutable std::mutex m_cb_mutex; + std::queue, callback_type>> m_cb_queue; + std::unordered_map> m_pixs; Cache m_cache; }; -- cgit v1.2.3