]> git.tdb.fi Git - libs/gl.git/blobdiff - source/resourcemanager.h
Implement automatic resource unloading based on age
[libs/gl.git] / source / resourcemanager.h
index 1e3cb54f3b439c72fe26811ccd546d6993743327..07b0aaf09f0574fe2ee8f6fbaea7be162f9660b7 100644 (file)
@@ -29,11 +29,13 @@ private:
                IO::Seekable *io;
                Resource::AsyncLoader *loader;
                bool loaded;
+               unsigned last_used;
 
                ManagedResource(Resource &);
 
                void start_loading();
                void finish_loading();
+               void unload();
        };
 
        class LoadingThread: public Thread
@@ -76,6 +78,10 @@ private:
        bool async_loads;
        ResourceMap resources;
        LoadQueue queue;
+       unsigned frame;
+       unsigned min_retain_frames;
+       unsigned max_retain_frames;
+       unsigned next_unload;
        LoadingThread thread;
 
 public:
@@ -84,6 +90,7 @@ public:
 
        void set_loading_policy(LoadingPolicy);
        void set_async_loads(bool);
+       void set_max_retain_frames(unsigned);
 
        void add_resource(Resource &);
        void *get_data_for_resource(const Resource &);