PebbleOS
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
circular_cache.h File Reference
#include <pbl/util/order.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Data Structures

struct  CircularCache
 Circular cache state. More...
 

Typedefs

typedef void(* CircularCacheItemDestructor) (void *item)
 Destructor called on an item about to be evicted or flushed.
 

Functions

void circular_cache_init (CircularCache *c, uint8_t *buffer, size_t item_size, int total_items, Comparator compare_cb)
 Initialize a circular cache.
 
void circular_cache_set_item_destructor (CircularCache *c, CircularCacheItemDestructor destructor)
 Set the destructor called on items when they are evicted or flushed.
 
bool circular_cache_contains (CircularCache *c, void *item)
 Check whether the cache contains an item.
 
void * circular_cache_get (CircularCache *c, void *theirs)
 Find an item in the cache.
 
void circular_cache_push (CircularCache *c, void *item)
 Copy an item into the cache, evicting the oldest one.
 
void circular_cache_fill (CircularCache *c, uint8_t *item)
 Set every slot of the cache to a copy of an item.
 
void circular_cache_flush (CircularCache *c)
 Call the destructor on every slot and restart eviction from the first one.