Files
Chloe M. bc11f9b58f stos: ob: Add object cache groundwork
Signed-off-by: Chloe M. <chloe@mensia.org>
2026-06-25 17:50:43 +00:00

58 lines
1.1 KiB
C

/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: Object manager cache
* Author: Chloe M.
*/
#ifndef _OB_CACHE_H_
#define _OB_CACHE_H_ 1
#include <stdef.h>
#include <ob/object.h>
/*
* An object cache allows deallocated objects to be recycled without
* the overhead of true deallocation and reallocation.
*
* @First: First cache entry
* @Last: Last cache entry
* @EntryCount: Number of entires in the cache
*/
typedef struct {
ST_OBJECT *First;
ST_OBJECT *Last;
USIZE EntryCount;
} OBJECT_CACHE;
extern OBJECT_CACHE gObCache;
/*
* Initialize object cache
*
* @Cache: Object cache to initialize
*/
VOID ObInitCache(OBJECT_CACHE *Cache);
/*
* Reclaim object to cache if the reference count is
* zero.
*
* @Cache: Cache to reclaim to
* @Object: Object to reclaim
*/
VOID ObReclaimToCache(OBJECT_CACHE *Cache, ST_OBJECT *Object);
/*
* Pop an entry for a zeroed object from the cache
*
* @Cache: Cache to pop from
*
* Returns an entry on success, otherwise NULL on
* failure
*/
ST_OBJECT *ObPopFromCache(OBJECT_CACHE *Cache);
#endif /* !_OB_CACHE_H_ */