Offers a simple cache mechanism for objects needed in submodules which are costly to construct or deconstruct.
Implements <initthread_objectcacheimpl> and <freethread_objectcacheimpl> to allocate storage for cached objects before a new thread is created and frees all storage before the thread exits.
Objectcache | Offers a simple cache mechanism for objects needed in submodules which are costly to construct or deconstruct. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file of Objectcache. |
C-kern/ | Implementation file Objectcache impl. |
Types | |
struct objectcache_impl_t | Export objectcache_impl_t. |
Functions | |
init | |
unittest_cache_objectcacheimpl | Test allocation and free works. |
objectcache_impl_t | Holds pointers to all cached objects. |
iobuffer | Used in ALLOC_PAGECACHE. |
initthread | |
interface_objectcacheimpl | This function is called from <init_threadcontext>. |
lifetime | |
objectcache_impl_FREE | Static initializer. |
init_objectcacheimpl | Inits objectcache_impl_t and all contained objects. |
free_objectcacheimpl | Frees objectcache_impl_t and all contained objects. |
access | |
lockiobuffer_objectcacheimpl | Locks the io buffer and returns a pointer to it in iobuffer. |
unlockiobuffer_objectcacheimpl | Unlocks the locked io buffer and sets the pointer to NULL. |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2011 Jörg Seebohn
Header file of Objectcache.
Implementation file Objectcache impl.
typedef struct objectcache_impl_t objectcache_impl_t
Export objectcache_impl_t.
init | |
unittest_cache_objectcacheimpl | Test allocation and free works. |
struct objectcache_impl_t
Holds pointers to all cached objects. TODO: remove iobuffer and add other types !
iobuffer | Used in ALLOC_PAGECACHE. |
initthread | |
interface_objectcacheimpl | This function is called from <init_threadcontext>. |
lifetime | |
objectcache_impl_FREE | Static initializer. |
init_objectcacheimpl | Inits objectcache_impl_t and all contained objects. |
free_objectcacheimpl | Frees objectcache_impl_t and all contained objects. |
access | |
lockiobuffer_objectcacheimpl | Locks the io buffer and returns a pointer to it in iobuffer. |
unlockiobuffer_objectcacheimpl | Unlocks the locked io buffer and sets the pointer to NULL. |
struct { uint8_t * addr ; size_t size ; } iobuffer
Used in ALLOC_PAGECACHE.
struct objectcache_it * interface_objectcacheimpl( void )
This function is called from <init_threadcontext>. Used to initialize interface of objectcache_t.
int init_objectcacheimpl( /*out*/objectcache_impl_t * objectcache )
Inits objectcache_impl_t and all contained objects.
int free_objectcacheimpl( objectcache_impl_t * objectcache )
Frees objectcache_impl_t and all contained objects.
void lockiobuffer_objectcacheimpl( objectcache_impl_t * objectcache, /*out*/struct memblock_t ** iobuffer )
Locks the io buffer and returns a pointer to it in iobuffer. The buffer is of type vmpage_t (compatible with memblock_t).
void unlockiobuffer_objectcacheimpl( objectcache_impl_t * objectcache, struct memblock_t ** iobuffer )
Unlocks the locked io buffer and sets the pointer to NULL. The pointer to the buffer must be acquired by a previous call to lockiobuffer_objectcacheimpl. Calling unlock with a NULL pointer is a no op.
Export objectcache_impl_t.
typedef struct objectcache_impl_t objectcache_impl_t
Holds pointers to all cached objects.
struct objectcache_impl_t
Test allocation and free works.
int unittest_cache_objectcacheimpl( void )
Used in ALLOC_PAGECACHE.
struct { uint8_t * addr ; size_t size ; } iobuffer
Allocates a single memory page of size pgsize (see pagesize_e) and returns it in page.
#define ALLOC_PAGECACHE( pgsize, page ) (allocpage_pagecache(pagecache_maincontext(), (pgsize), (page)))
This function is called from init_threadcontext.
struct objectcache_it * interface_objectcacheimpl( void )
Static initializer.
#define objectcache_impl_FREE { vmpage_FREE }
Inits objectcache_impl_t and all contained objects.
int init_objectcacheimpl( /*out*/objectcache_impl_t * objectcache )
Frees objectcache_impl_t and all contained objects.
int free_objectcacheimpl( objectcache_impl_t * objectcache )
Locks the io buffer and returns a pointer to it in iobuffer.
void lockiobuffer_objectcacheimpl( objectcache_impl_t * objectcache, /*out*/struct memblock_t ** iobuffer )
Unlocks the locked io buffer and sets the pointer to NULL.
void unlockiobuffer_objectcacheimpl( objectcache_impl_t * objectcache, struct memblock_t ** iobuffer )
Uses iobj_DECLARE to declare interfaceable object.
iobj_DECLARE( objectcache_t, objectcache )
Type has same structure as memblock_t.
struct vmpage_t
Describes memory block.
struct memblock_t