|
Packit Service |
20376f |
/*
|
|
Packit Service |
20376f |
* Copyright (C) the libgit2 contributors. All rights reserved.
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
|
Packit Service |
20376f |
* a Linking Exception. For full terms see the included COPYING file.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
#ifndef INCLUDE_cache_h__
|
|
Packit Service |
20376f |
#define INCLUDE_cache_h__
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#include "git2/common.h"
|
|
Packit Service |
20376f |
#include "git2/oid.h"
|
|
Packit Service |
20376f |
#include "git2/odb.h"
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#include "thread-utils.h"
|
|
Packit Service |
20376f |
#include "oidmap.h"
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
enum {
|
|
Packit Service |
20376f |
GIT_CACHE_STORE_ANY = 0,
|
|
Packit Service |
20376f |
GIT_CACHE_STORE_RAW = 1,
|
|
Packit Service |
20376f |
GIT_CACHE_STORE_PARSED = 2
|
|
Packit Service |
20376f |
};
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
typedef struct {
|
|
Packit Service |
20376f |
git_oid oid;
|
|
Packit Service |
20376f |
int16_t type; /* git_otype value */
|
|
Packit Service |
20376f |
uint16_t flags; /* GIT_CACHE_STORE value */
|
|
Packit Service |
20376f |
size_t size;
|
|
Packit Service |
20376f |
git_atomic refcount;
|
|
Packit Service |
20376f |
} git_cached_obj;
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
typedef struct {
|
|
Packit Service |
20376f |
git_oidmap *map;
|
|
Packit Service |
20376f |
git_rwlock lock;
|
|
Packit Service |
20376f |
ssize_t used_memory;
|
|
Packit Service |
20376f |
} git_cache;
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
extern bool git_cache__enabled;
|
|
Packit Service |
20376f |
extern ssize_t git_cache__max_storage;
|
|
Packit Service |
20376f |
extern git_atomic_ssize git_cache__current_storage;
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
int git_cache_set_max_object_size(git_otype type, size_t size);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
int git_cache_init(git_cache *cache);
|
|
Packit Service |
20376f |
void git_cache_free(git_cache *cache);
|
|
Packit Service |
20376f |
void git_cache_clear(git_cache *cache);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
void *git_cache_store_raw(git_cache *cache, git_odb_object *entry);
|
|
Packit Service |
20376f |
void *git_cache_store_parsed(git_cache *cache, git_object *entry);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
git_odb_object *git_cache_get_raw(git_cache *cache, const git_oid *oid);
|
|
Packit Service |
20376f |
git_object *git_cache_get_parsed(git_cache *cache, const git_oid *oid);
|
|
Packit Service |
20376f |
void *git_cache_get_any(git_cache *cache, const git_oid *oid);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
GIT_INLINE(size_t) git_cache_size(git_cache *cache)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
return (size_t)git_oidmap_size(cache->map);
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
GIT_INLINE(void) git_cached_obj_incref(void *_obj)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
git_cached_obj *obj = _obj;
|
|
Packit Service |
20376f |
git_atomic_inc(&obj->refcount);
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
void git_cached_obj_decref(void *_obj);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#endif
|