summaryrefslogtreecommitdiffstats
path: root/libass/ass_cache.h
diff options
context:
space:
mode:
authorDr.Smile <vabnick@gmail.com>2015-09-15 20:18:17 +0300
committerDr.Smile <vabnick@gmail.com>2016-06-30 23:13:53 +0300
commit25d65abce1a0fabe3c3bf81f1ee7ee7f24b91a4e (patch)
treea5d82da3707fcf2801a960fbea70ccfca4052469 /libass/ass_cache.h
parent7d05b1d3b8d08672bd7297516514396d1d1a846f (diff)
downloadlibass-25d65abce1a0fabe3c3bf81f1ee7ee7f24b91a4e.tar.bz2
libass-25d65abce1a0fabe3c3bf81f1ee7ee7f24b91a4e.tar.xz
cache: switch to gradual cache clearing
Advantages over the old algorithm consist of the following. * There are no glitches due to full cache clearing. Items are arranged into linked list ordered by time of last use. Only the oldest items get deleted at the clearing event. * Each item now keeps track of number of references. Referenced cache values are immune to clearing. * Reduced amount of total cache memory for the same performance. * Reduced number of memory allocations per cache item.
Diffstat (limited to 'libass/ass_cache.h')
-rw-r--r--libass/ass_cache.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/libass/ass_cache.h b/libass/ass_cache.h
index af814ac..63e9e59 100644
--- a/libass/ass_cache.h
+++ b/libass/ass_cache.h
@@ -106,11 +106,16 @@ typedef struct {
Cache *ass_cache_create(HashFunction hash_func, HashCompare compare_func,
CacheItemDestructor destruct_func, ItemSize size_func,
size_t key_size, size_t value_size);
-void *ass_cache_put(Cache *cache, void *key, void *value);
-void *ass_cache_get(Cache *cache, void *key);
-int ass_cache_empty(Cache *cache, size_t max_size);
+bool ass_cache_get(Cache *cache, void *key, void *value_ptr);
+void *ass_cache_get_key(void *value);
+void ass_cache_commit(void *value);
+void ass_cache_cancel(void *value);
+void ass_cache_inc_ref(void *value);
+void ass_cache_dec_ref(void *value);
+void ass_cache_cut(Cache *cache, size_t max_size);
void ass_cache_stats(Cache *cache, size_t *size, unsigned *hits,
unsigned *misses, unsigned *count);
+void ass_cache_empty(Cache *cache);
void ass_cache_done(Cache *cache);
Cache *ass_font_cache_create(void);
Cache *ass_outline_cache_create(void);