]> git.tdb.fi Git - libs/gl.git/blobdiff - source/resourcemanager.h
Implement automatic unloading when a total size limit is exceeded
[libs/gl.git] / source / resourcemanager.h
index 07b0aaf09f0574fe2ee8f6fbaea7be162f9660b7..60f61a421fe4b2b54685a2366cd339e9bfa9be2d 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MSP_GL_RESOURCEMANAGER_H_
 #define MSP_GL_RESOURCEMANAGER_H_
 
+#include <msp/core/inttypes.h>
 #include <msp/core/mutex.h>
 #include <msp/core/semaphore.h>
 #include <msp/core/thread.h>
@@ -30,6 +31,7 @@ private:
                Resource::AsyncLoader *loader;
                bool loaded;
                unsigned last_used;
+               UInt64 data_size;
 
                ManagedResource(Resource &);
 
@@ -78,6 +80,7 @@ private:
        bool async_loads;
        ResourceMap resources;
        LoadQueue queue;
+       UInt64 size_limit;
        unsigned frame;
        unsigned min_retain_frames;
        unsigned max_retain_frames;
@@ -90,6 +93,8 @@ public:
 
        void set_loading_policy(LoadingPolicy);
        void set_async_loads(bool);
+       void set_size_limit(UInt64);
+       void set_min_retain_frames(unsigned);
        void set_max_retain_frames(unsigned);
 
        void add_resource(Resource &);
@@ -100,6 +105,7 @@ public:
        void remove_resource(Resource &);
 
        void tick();
+       UInt64 get_total_data_size() const;
 };
 
 } // namespace GL