summaryrefslogtreecommitdiff
path: root/src/cache.h
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2013-04-01 19:38:23 +0200
committerVicent Marti <tanoku@gmail.com>2013-04-22 16:50:50 +0200
commit5df184241a6cfe88ac5ebcee9a3ad175abfca0cd (patch)
tree36136d01b6016204b5ee9b08a4efe93bf6813613 /src/cache.h
parenta92dd316079250b27cc933b1fd00cd6af88b88d9 (diff)
downloadlibgit2-5df184241a6cfe88ac5ebcee9a3ad175abfca0cd.tar.gz
lol this worked first try wtf
Diffstat (limited to 'src/cache.h')
-rw-r--r--src/cache.h33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/cache.h b/src/cache.h
index 7034ec268..f30af9c3e 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -12,30 +12,35 @@
#include "git2/odb.h"
#include "thread-utils.h"
+#include "oidmap.h"
-#define GIT_DEFAULT_CACHE_SIZE 128
-
-typedef void (*git_cached_obj_freeptr)(void *);
+enum {
+ GIT_CACHE_STORE_ANY = 0,
+ GIT_CACHE_STORE_RAW = 1,
+ GIT_CACHE_STORE_PARSED = 2
+};
typedef struct {
git_oid oid;
git_atomic refcount;
+ uint32_t flags;
} git_cached_obj;
typedef struct {
- git_cached_obj **nodes;
+ git_oidmap *map;
git_mutex lock;
-
unsigned int lru_count;
- size_t size_mask;
- git_cached_obj_freeptr free_obj;
} git_cache;
-int git_cache_init(git_cache *cache, size_t size, git_cached_obj_freeptr free_ptr);
+int git_cache_init(git_cache *cache);
void git_cache_free(git_cache *cache);
-void *git_cache_try_store(git_cache *cache, void *entry);
-void *git_cache_get(git_cache *cache, const git_oid *oid);
+void *git_cache_store_raw(git_cache *cache, git_odb_object *entry);
+void *git_cache_store_parsed(git_cache *cache, git_object *entry);
+
+git_odb_object *git_cache_get_raw(git_cache *cache, const git_oid *oid);
+git_object *git_cache_get_parsed(git_cache *cache, const git_oid *oid);
+void *git_cache_get_any(git_cache *cache, const git_oid *oid);
GIT_INLINE(void) git_cached_obj_incref(void *_obj)
{
@@ -43,12 +48,6 @@ GIT_INLINE(void) git_cached_obj_incref(void *_obj)
git_atomic_inc(&obj->refcount);
}
-GIT_INLINE(void) git_cached_obj_decref(void *_obj, git_cached_obj_freeptr free_obj)
-{
- git_cached_obj *obj = _obj;
-
- if (git_atomic_dec(&obj->refcount) == 0)
- free_obj(obj);
-}
+void git_cached_obj_decref(void *_obj);
#endif