Back to index

avfs  1.0.1
Functions
cache.h File Reference
#include "avfs.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void av_cache_checkspace ()
void av_cache_diskfull ()
struct cacheobjav_cacheobj_new (void *obj, const char *name)
 cache V1 interface using external cache objects The object created by _new is not referenced by the cache itself so the user has to take care of this.
void * av_cacheobj_get (struct cacheobj *cobj)
void av_cacheobj_setsize (struct cacheobj *cobj, avoff_t diskusage)
int av_cache2_set (void *obj, const char *name)
 cache V2 interface using internal cache objects The interface doesn't returns the cache object storing the obj.
void * av_cache2_get (const char *name)
void av_cache2_setsize (const char *name, avoff_t diskusage)

Function Documentation

void* av_cache2_get ( const char *  name)

Definition at line 411 of file cache.c.

{
    struct cacheobj *cobj;
    void *obj = NULL;
    
    AV_LOCK(cachelock);
    cobj = cacheobj2_find(name);
    if(cobj != NULL) {
        cacheobj_remove(cobj);
        cacheobj_insert(cobj);
        obj = cobj->obj;
        av_ref_obj(obj);
    }
    AV_UNLOCK(cachelock);

    return obj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_cache2_set ( void *  obj,
const char *  name 
)

cache V2 interface using internal cache objects The interface doesn't returns the cache object storing the obj.

The name is used to access the object.

Definition at line 382 of file cache.c.

{
    struct cacheobj *cobj, *oldcobj;

    if(obj != NULL) {
        AV_NEW_OBJ(cobj, cacheobj_internal_delete);
        cobj->obj = obj;
        cobj->diskusage = 0;
        cobj->name = av_strdup(name);
        cobj->internal_obj = 1;
        av_ref_obj(obj);
    } else {
        cobj = NULL;
    }

    AV_LOCK(cachelock);
    oldcobj = cacheobj2_find(name);

    if(oldcobj != NULL )
        av_unref_obj(oldcobj);

    if(cobj != NULL)
        cacheobj_insert(cobj);

    AV_UNLOCK(cachelock);

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void av_cache2_setsize ( const char *  name,
avoff_t  diskusage 
)

Definition at line 429 of file cache.c.

{
    struct cacheobj *cobj;

    AV_LOCK(cachelock);
    cobj = cacheobj2_find(name);
    if(cobj->obj != NULL && cobj->diskusage != diskusage) {
        disk_usage -= cobj->diskusage;
        cobj->diskusage = diskusage;
        disk_usage += cobj->diskusage;
        
        cache_checkspace(0, cobj);
    }
    AV_UNLOCK(cachelock);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 319 of file cache.c.

{
    AV_LOCK(cachelock);
    cache_checkspace(0,NULL);
    AV_UNLOCK(cachelock);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 326 of file cache.c.

{
    AV_LOCK(cachelock);
    cache_checkspace(1,NULL);
    AV_UNLOCK(cachelock);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* av_cacheobj_get ( struct cacheobj cobj)

Definition at line 347 of file cache.c.

{
    void *obj;

    if(cobj == NULL)
        return NULL;

    AV_LOCK(cachelock);
    obj = cobj->obj;
    if(obj != NULL) {
        cacheobj_remove(cobj);
        cacheobj_insert(cobj);
        av_ref_obj(obj);
    }
    AV_UNLOCK(cachelock);

    return obj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct cacheobj* av_cacheobj_new ( void *  obj,
const char *  name 
) [read]

cache V1 interface using external cache objects The object created by _new is not referenced by the cache itself so the user has to take care of this.

The object is required to access to object stored in the cache.

Definition at line 234 of file cache.c.

{
    struct cacheobj *cobj;

    if(obj == NULL)
        return NULL;

    AV_NEW_OBJ(cobj, cacheobj_delete);
    cobj->obj = obj;
    cobj->diskusage = 0;
    cobj->name = av_strdup(name);
    cobj->internal_obj = 0;
    av_ref_obj(obj);

    AV_LOCK(cachelock);
    cacheobj_insert(cobj);
    AV_UNLOCK(cachelock);

    return cobj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void av_cacheobj_setsize ( struct cacheobj cobj,
avoff_t  diskusage 
)

Definition at line 334 of file cache.c.

{
    AV_LOCK(cachelock);
    if(cobj->obj != NULL && cobj->diskusage != diskusage) {
        disk_usage -= cobj->diskusage;
        cobj->diskusage = diskusage;
        disk_usage += cobj->diskusage;
        
        cache_checkspace(0, cobj);
    }
    AV_UNLOCK(cachelock);
}

Here is the call graph for this function:

Here is the caller graph for this function: