gwenhywfar  5.9.0
Typedefs
Multi Cache Module

This file contains the definition of a GWEN_MULTICACHE, a cache for multiple types of data. More...

Collaboration diagram for Multi Cache Module:

Typedefs

typedef struct GWEN_MULTICACHE GWEN_MULTICACHE
 
typedef struct GWEN_MULTICACHE_TYPE GWEN_MULTICACHE_TYPE
 
typedef int GWENHYWFAR_CB(* GWEN_MULTICACHE_TYPE_ATTACH_FN) (void *p)
 
typedef int GWENHYWFAR_CB(* GWEN_MULTICACHE_TYPE_ATTACH_OBJECT_FN) (const GWEN_MULTICACHE_TYPE *ct, void *p)
 
typedef int GWENHYWFAR_CB(* GWEN_MULTICACHE_TYPE_FREE_FN) (void *p)
 
typedef int GWENHYWFAR_CB(* GWEN_MULTICACHE_TYPE_FREE_OBJECT_FN) (const GWEN_MULTICACHE_TYPE *ct, void *p)
 

Per-type Cache Objects

This object describes one of the data types which can be managed by a central cache object.

GWENHYWFAR_API GWEN_MULTICACHE_TYPEGWEN_MultiCache_Type_new (GWEN_MULTICACHE *mc)
 
GWENHYWFAR_API void GWEN_MultiCache_Type_free (GWEN_MULTICACHE_TYPE *ct)
 
GWENHYWFAR_API void * GWEN_MultiCache_Type_GetData (const GWEN_MULTICACHE_TYPE *ct, uint32_t id)
 
GWENHYWFAR_API void * GWEN_MultiCache_Type_GetDataWithParams (const GWEN_MULTICACHE_TYPE *ct, uint32_t id, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4)
 
GWENHYWFAR_API void * GWEN_MultiCache_Type_GetDataWithParams5 (const GWEN_MULTICACHE_TYPE *ct, uint32_t id, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4, double param5)
 
GWENHYWFAR_API void GWEN_MultiCache_Type_SetData (GWEN_MULTICACHE_TYPE *ct, uint32_t id, void *ptr, uint32_t size)
 
GWENHYWFAR_API void GWEN_MultiCache_Type_SetDataWithParams (GWEN_MULTICACHE_TYPE *ct, uint32_t id, void *ptr, uint32_t size, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4)
 
GWENHYWFAR_API void GWEN_MultiCache_Type_SetDataWithParams5 (GWEN_MULTICACHE_TYPE *ct, uint32_t id, void *ptr, uint32_t size, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4, double param5)
 
GWENHYWFAR_API void GWEN_MultiCache_Type_PurgeData (GWEN_MULTICACHE_TYPE *ct, uint32_t id)
 
GWENHYWFAR_API void GWEN_MultiCache_Type_PurgeAll (GWEN_MULTICACHE_TYPE *ct)
 
GWENHYWFAR_API GWEN_IDLIST64GWEN_MultiCache_Type_GetIdsInCache (const GWEN_MULTICACHE_TYPE *ct)
 
GWENHYWFAR_API void GWEN_MultiCache_Type_SetAttachFn (GWEN_MULTICACHE_TYPE *ct, GWEN_MULTICACHE_TYPE_ATTACH_FN fn)
 
GWENHYWFAR_API void GWEN_MultiCache_Type_SetFreeFn (GWEN_MULTICACHE_TYPE *ct, GWEN_MULTICACHE_TYPE_FREE_FN fn)
 
GWENHYWFAR_API void GWEN_MultiCache_Type_SetAttachObjectFn (GWEN_MULTICACHE_TYPE *ct, GWEN_MULTICACHE_TYPE_ATTACH_OBJECT_FN fn)
 
GWENHYWFAR_API void GWEN_MultiCache_Type_SetFreeObjectFn (GWEN_MULTICACHE_TYPE *ct, GWEN_MULTICACHE_TYPE_FREE_OBJECT_FN fn)
 

Central Cache Object

This is the central cache object which can hold multiple types of data.

GWENHYWFAR_API GWEN_MULTICACHEGWEN_MultiCache_new (uint64_t maxSize)
 
GWENHYWFAR_API void GWEN_MultiCache_free (GWEN_MULTICACHE *mc)
 
GWENHYWFAR_API uint64_t GWEN_MultiCache_GetMaxSizeUsed (const GWEN_MULTICACHE *mc)
 
GWENHYWFAR_API int GWEN_MultiCache_GetUsageString (const GWEN_MULTICACHE *mc, char *ptrBuffer, int lenBuffer)
 

Detailed Description

This file contains the definition of a GWEN_MULTICACHE, a cache for multiple types of data.

The idea behind this is to make it easier to handle multiple types of objects by a single central cache object. You only set the maximum total size the central cache object is allowed to provide and that object will use this sum of memory to provide a caching mechanism for multiple different types.

You'll have to create a single central cache object (GWEN_MULTICACHE). Then you can create a GWEN_MULTICACHE_TYPE object for each kind of data you want to have managed. For the GWEN_MULTICACHE_TYPE object you need to provide functions which will increase and decrease the reference counter of the object cached.

Typedef Documentation

Definition at line 59 of file multicache.h.

Definition at line 60 of file multicache.h.

typedef int GWENHYWFAR_CB(* GWEN_MULTICACHE_TYPE_ATTACH_FN) (void *p)

Definition at line 63 of file multicache.h.

typedef int GWENHYWFAR_CB(* GWEN_MULTICACHE_TYPE_ATTACH_OBJECT_FN) (const GWEN_MULTICACHE_TYPE *ct, void *p)

Definition at line 66 of file multicache.h.

typedef int GWENHYWFAR_CB(* GWEN_MULTICACHE_TYPE_FREE_FN) (void *p)

Definition at line 64 of file multicache.h.

typedef int GWENHYWFAR_CB(* GWEN_MULTICACHE_TYPE_FREE_OBJECT_FN) (const GWEN_MULTICACHE_TYPE *ct, void *p)

Definition at line 67 of file multicache.h.

Function Documentation

GWENHYWFAR_API void GWEN_MultiCache_free ( GWEN_MULTICACHE mc)

Definition at line 525 of file multicache.c.

References DBG_NOTICE, GWEN_FREE_OBJECT, GWEN_LOGDOMAIN, and GWEN_MultiCache_ReleaseEntry().

Here is the call graph for this function:

GWENHYWFAR_API uint64_t GWEN_MultiCache_GetMaxSizeUsed ( const GWEN_MULTICACHE mc)

Definition at line 603 of file multicache.c.

GWENHYWFAR_API int GWEN_MultiCache_GetUsageString ( const GWEN_MULTICACHE mc,
char *  ptrBuffer,
int  lenBuffer 
)

Definition at line 567 of file multicache.c.

References DBG_ERROR, GWEN_ERROR_BUFFER_OVERFLOW, and GWEN_LOGDOMAIN.

GWENHYWFAR_API GWEN_MULTICACHE* GWEN_MultiCache_new ( uint64_t  maxSize)

Definition at line 510 of file multicache.c.

References GWEN_NEW_OBJECT.

GWENHYWFAR_API void GWEN_MultiCache_Type_free ( GWEN_MULTICACHE_TYPE ct)

Definition at line 204 of file multicache.c.

References GWEN_FREE_OBJECT, GWEN_LIST_FINI, and GWEN_MultiCache_ReleaseEntriesForType().

Here is the call graph for this function:

GWENHYWFAR_API void* GWEN_MultiCache_Type_GetData ( const GWEN_MULTICACHE_TYPE ct,
uint32_t  id 
)
GWENHYWFAR_API void* GWEN_MultiCache_Type_GetDataWithParams ( const GWEN_MULTICACHE_TYPE ct,
uint32_t  id,
uint32_t  param1,
uint32_t  param2,
uint32_t  param3,
uint32_t  param4 
)
GWENHYWFAR_API void* GWEN_MultiCache_Type_GetDataWithParams5 ( const GWEN_MULTICACHE_TYPE ct,
uint32_t  id,
uint32_t  param1,
uint32_t  param2,
uint32_t  param3,
uint32_t  param4,
double  param5 
)
GWENHYWFAR_API GWEN_IDLIST64* GWEN_MultiCache_Type_GetIdsInCache ( const GWEN_MULTICACHE_TYPE ct)

Definition at line 475 of file multicache.c.

References GWEN_IdList64_AddId(), GWEN_IdList64_free(), GWEN_IdList64_GetEntryCount(), GWEN_IdList64_new(), GWEN_MultiCache_Entry_GetCacheType(), and NULL.

Here is the call graph for this function:

GWENHYWFAR_API GWEN_MULTICACHE_TYPE* GWEN_MultiCache_Type_new ( GWEN_MULTICACHE mc)

Definition at line 189 of file multicache.c.

References GWEN_IdMapAlgo_Hex4, GWEN_LIST_INIT, and GWEN_NEW_OBJECT.

GWENHYWFAR_API void GWEN_MultiCache_Type_PurgeAll ( GWEN_MULTICACHE_TYPE ct)

Definition at line 380 of file multicache.c.

References GWEN_MultiCache_ReleaseEntriesForType().

Here is the call graph for this function:

GWENHYWFAR_API void GWEN_MultiCache_Type_PurgeData ( GWEN_MULTICACHE_TYPE ct,
uint32_t  id 
)

Definition at line 366 of file multicache.c.

References GWEN_MultiCache_ReleaseEntry().

Referenced by GWEN_MultiCache_Type_SetData(), GWEN_MultiCache_Type_SetDataWithParams(), and GWEN_MultiCache_Type_SetDataWithParams5().

Here is the call graph for this function:

Here is the caller graph for this function:

GWENHYWFAR_API void GWEN_MultiCache_Type_SetAttachFn ( GWEN_MULTICACHE_TYPE ct,
GWEN_MULTICACHE_TYPE_ATTACH_FN  fn 
)

Definition at line 390 of file multicache.c.

GWENHYWFAR_API void GWEN_MultiCache_Type_SetAttachObjectFn ( GWEN_MULTICACHE_TYPE ct,
GWEN_MULTICACHE_TYPE_ATTACH_OBJECT_FN  fn 
)

Definition at line 410 of file multicache.c.

GWENHYWFAR_API void GWEN_MultiCache_Type_SetData ( GWEN_MULTICACHE_TYPE ct,
uint32_t  id,
void *  ptr,
uint32_t  size 
)

Definition at line 307 of file multicache.c.

References GWEN_MultiCache_AddEntry(), GWEN_MultiCache_Entry_new(), and GWEN_MultiCache_Type_PurgeData().

Here is the call graph for this function:

GWENHYWFAR_API void GWEN_MultiCache_Type_SetDataWithParams ( GWEN_MULTICACHE_TYPE ct,
uint32_t  id,
void *  ptr,
uint32_t  size,
uint32_t  param1,
uint32_t  param2,
uint32_t  param3,
uint32_t  param4 
)
GWENHYWFAR_API void GWEN_MultiCache_Type_SetDataWithParams5 ( GWEN_MULTICACHE_TYPE ct,
uint32_t  id,
void *  ptr,
uint32_t  size,
uint32_t  param1,
uint32_t  param2,
uint32_t  param3,
uint32_t  param4,
double  param5 
)
GWENHYWFAR_API void GWEN_MultiCache_Type_SetFreeFn ( GWEN_MULTICACHE_TYPE ct,
GWEN_MULTICACHE_TYPE_FREE_FN  fn 
)

Definition at line 400 of file multicache.c.

GWENHYWFAR_API void GWEN_MultiCache_Type_SetFreeObjectFn ( GWEN_MULTICACHE_TYPE ct,
GWEN_MULTICACHE_TYPE_FREE_OBJECT_FN  fn 
)

Definition at line 420 of file multicache.c.