4 // CICache for quickly reading data that is hard to decompress yet used
7 // Actual caching is done in the File object
8 // the CICache keeps files open while rendering.
10 // Since the CICache outlives EDLs it must copy every parameter given to it.
12 // Files given as arguments must outlive the cache.
14 #include "arraylist.h"
17 #include "condition.inc"
23 #include "pluginserver.inc"
24 #include "preferences.inc"
28 class CICacheItem
: public ListItem
<CICacheItem
>, public GarbageObject
31 CICacheItem(CICache
*cache
, EDL
*edl
, Asset
*asset
);
36 // Number of last get or put operation involving this object.
38 Asset
*asset
; // Copy of asset. CICache should outlive EDLs.
45 class CICache
: public List
<CICacheItem
>
48 CICache(Preferences
*preferences
,
49 ArrayList
<PluginServer
*> *plugindb
);
52 friend class CICacheItem
;
54 // Enter a new file into the cache which is already open.
55 // If the file doesn't exist return the arguments.
56 // If the file exists delete the arguments and return the file which exists.
57 // void update(File* &file);
58 // void set_edl(EDL *edl);
60 // open it, lock it and add it to the cache if it isn't here already
61 // If it's already checked out, the value of block causes it to wait
62 // until it's checked in.
63 File
* check_out(Asset
*asset
, EDL
*edl
, int block
= 1);
65 // unlock a file from the cache
66 int check_in(Asset
*asset
);
68 // delete an entry from the cache
69 // before deleting an asset, starting a new project or something
70 int delete_entry(Asset
*asset
);
71 int delete_entry(char *path
);
72 // Remove all entries from the cache.
75 // Get ID of oldest member.
76 // Called by MWindow::age_caches.
78 int64_t get_memory_usage(int use_lock
);
80 // Called by age() and MWindow::age_caches
81 // returns 1 if nothing was available to delete
85 // Called by check_in() and modules.
86 // deletes oldest assets until under the memory limit
92 ArrayList
<PluginServer
*> *plugindb
;
100 // to prevent one from checking the same asset out before it's checked in
101 // yet without blocking the asset trying to get checked in
102 // use a seperate mutex for checkouts and checkins
104 Condition
*check_out_lock
;
107 Preferences
*preferences
;