- static const uint8_t *load_image(const std::string &filename);
- static std::map<std::string, std::unique_ptr<uint8_t[]>> all_images;
+ struct Image {
+ unsigned width, height;
+ std::unique_ptr<uint8_t[]> pixels;
+ timespec last_modified;
+ };
+
+ std::string filename, pathname;
+ std::shared_ptr<const Image> current_image;
+
+ static std::shared_ptr<const Image> load_image(const std::string &filename, const std::string &pathname);
+ static std::shared_ptr<const Image> load_image_raw(const std::string &pathname);
+ static void update_thread_func(const std::string &filename, const std::string &pathname, const timespec &first_modified);
+ static std::mutex all_images_lock;
+ static std::map<std::string, std::shared_ptr<const Image>> all_images;
+ static std::map<std::string, std::thread> update_threads;
+
+ static std::mutex threads_should_quit_mu;
+ static bool threads_should_quit; // Under threads_should_quit_mu.
+ static std::condition_variable threads_should_quit_modified; // Signals when threads_should_quit is set.