]> git.sesse.net Git - nageru/blobdiff - image_input.h
Factor out rewinding code in its own member function.
[nageru] / image_input.h
index 437d9c2db72ace8b45de8698d2f61c2147ce3786..f38426441b0691a73dd6b0cd94f2840a3ff3906c 100644 (file)
@@ -5,6 +5,7 @@
 #include <movit/flat_input.h>
 #include <stdbool.h>
 #include <time.h>
+#include <condition_variable>
 #include <cstdint>
 #include <map>
 #include <memory>
@@ -25,6 +26,7 @@ public:
        
 private:
        struct Image {
+               unsigned width, height;
                std::unique_ptr<uint8_t[]> pixels;
                timespec last_modified;
        };
@@ -38,7 +40,18 @@ private:
        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 volatile bool threads_should_quit;
+
+       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.
 };
 
+// Look for the file in all theme_dirs until we find one;
+// that will be the permanent resolution of this file, whether
+// it is actually valid or not. Returns an empty string on error.
+std::string search_for_file(const std::string &filename);
+
+// Same, but exits on error.
+std::string search_for_file_or_die(const std::string &filename);
+
 #endif // !defined(_IMAGE_INPUT_H)