Objectcache-Object

Offers object and interface for accessing cached objects.  Implemented by objectcache_impl_t.

Summary
Objectcache-ObjectOffers object and interface for accessing cached objects.
CopyrightThis program is free software.
Files
C-kern/api/cache/objectcache.hHeader file of Objectcache-Object.
Types
struct objectcache_tExport objectcache_t.
struct objectcache_itExport interface objectcache_it.
objectcache_tUses iobj_DECLARE to declare interfaceable object.
lifetime
objectcache_FREEStatic initializer.
objectcache_itThe function table which describes the objectcache service.
lock_iobufferSee objectcache_impl_t.lockiobuffer_objectcacheimpl for an implementation.
unlock_iobufferSee objectcache_impl_t.unlockiobuffer_objectcacheimpl for an implementation.
generic
genericcast_objectcacheitCasts first parameter into pointer to objectcache_it.
objectcache_it_DECLAREDeclares a function table for accessing an objectcache service.
inline implementation
Macros
genericcast_objectcacheitImplements objectcache_it.genericcast_objectcacheit.
objectcache_it_DECLAREImplements objectcache_it.objectcache_it_DECLARE.

Copyright

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.

Author

© 2011 Jörg Seebohn

Files

C-kern/api/cache/objectcache.h

Header file of Objectcache-Object.

Types

struct objectcache_t

typedef struct objectcache_t objectcache_t

Export objectcache_tobjectcache_it implementing object.

struct objectcache_it

typedef struct objectcache_it objectcache_it

Export interface objectcache_it.

objectcache_t

iobj_DECLARE(objectcache_t,
objectcache)

Uses iobj_DECLARE to declare interfaceable object.  See also objectcache_impl_t which is the default implementation.

Summary
lifetime
objectcache_FREEStatic initializer.

lifetime

objectcache_FREE

#define objectcache_FREE iobj_FREE

Static initializer.

objectcache_it

struct objectcache_it

The function table which describes the objectcache service.  See objectcache_it_DECLARE for adaption of the interface to a specific implementation.

Summary
lock_iobufferSee objectcache_impl_t.lockiobuffer_objectcacheimpl for an implementation.
unlock_iobufferSee objectcache_impl_t.unlockiobuffer_objectcacheimpl for an implementation.
generic
genericcast_objectcacheitCasts first parameter into pointer to objectcache_it.
objectcache_it_DECLAREDeclares a function table for accessing an objectcache service.

lock_iobuffer

void (
   *lock_iobuffer
) (struct objectcache_t * cache, /*out*/struct memblock_t ** iobuffer)

See objectcache_impl_t.lockiobuffer_objectcacheimpl for an implementation.

unlock_iobuffer

void (
   *unlock_iobuffer
) (struct objectcache_t * cache, struct memblock_t ** iobuffer)

See objectcache_impl_t.unlockiobuffer_objectcacheimpl for an implementation.

generic

genericcast_objectcacheit

objectcache_it * genericcast_objectcacheit(void *cache,
TYPENAME objectcache_t) ;

Casts first parameter into pointer to objectcache_it.  The first parameter has to point to a type declared with objectcache_it_DECLARE.  The second must be the same as in objectcache_it_DECLARE.

objectcache_it_DECLARE

void objectcache_it_DECLARE(TYPENAME declared_it,
TYPENAME objectcache_t) ;

Declares a function table for accessing an objectcache service.  Use this macro to define an interface which is structural compatible with the generic interface objectcache_it.  The difference between the newly declared interface and the generic interface is the type of the first parameter.

See objectcache_it for a list of declared functions.

Parameter

declared_itThe name of the structure which is declared as the functional objectcache interface.  The name should have the suffix “_it”.
objectcache_tThe type of the cache object which is the first parameter of all objectcache functions.

Macros

genericcast_objectcacheit

#define genericcast_objectcacheit(
   cache,
   objectcache_t
) ( __extension__ ({ static_assert( offsetof(objectcache_it, lock_iobuffer) == offsetof(typeof(*(cache)), lock_iobuffer) && offsetof(objectcache_it, unlock_iobuffer) == offsetof(typeof(*(cache)), unlock_iobuffer), "ensure same structure") ; if (0) { (cache)->lock_iobuffer((objectcache_t*)0, (struct memblock_t**)0) ; (cache)->unlock_iobuffer((objectcache_t*)0, (struct memblock_t**)0) ; } (objectcache_it*) (cache) ; }))

Implements objectcache_it.genericcast_objectcacheit.

objectcache_it_DECLARE

#define objectcache_it_DECLARE(
   declared_it,
   objectcache_t
) typedef struct declared_it declared_it ; struct declared_it { void (*lock_iobuffer) (objectcache_t * cache, /*out*/struct memblock_t ** iobuffer); void (*unlock_iobuffer) (objectcache_t * cache, struct memblock_t ** iobuffer) ; }

Implements objectcache_it.objectcache_it_DECLARE.

Offers object and interface for accessing cached objects.
typedef struct objectcache_t objectcache_t
Export objectcache_t.
iobj_DECLARE(objectcache_t,
objectcache)
Uses iobj_DECLARE to declare interfaceable object.
typedef struct objectcache_it objectcache_it
Export interface objectcache_it.
struct objectcache_it
The function table which describes the objectcache service.
#define iobj_DECLARE(
   declared_t,
   typenameprefix
) struct declared_t { struct typenameprefix##_t * object ; struct typenameprefix##_it * iimpl ; }
Implements iobj_t.iobj_DECLARE.
#define objectcache_FREE iobj_FREE
Static initializer.
void (
   *lock_iobuffer
) (struct objectcache_t * cache, /*out*/struct memblock_t ** iobuffer)
See objectcache_impl_t.lockiobuffer_objectcacheimpl for an implementation.
void lockiobuffer_objectcacheimpl(objectcache_impl_t *objectcache,
/*out*/struct memblock_t **iobuffer)
Locks the io buffer and returns a pointer to it in iobuffer.
void (
   *unlock_iobuffer
) (struct objectcache_t * cache, struct memblock_t ** iobuffer)
See objectcache_impl_t.unlockiobuffer_objectcacheimpl for an implementation.
void unlockiobuffer_objectcacheimpl(objectcache_impl_t *objectcache,
struct memblock_t **iobuffer)
Unlocks the locked io buffer and sets the pointer to NULL.
objectcache_it * genericcast_objectcacheit(void *cache,
TYPENAME objectcache_t) ;
Casts first parameter into pointer to objectcache_it.
void objectcache_it_DECLARE(TYPENAME declared_it,
TYPENAME objectcache_t) ;
Declares a function table for accessing an objectcache service.
#define genericcast_objectcacheit(
   cache,
   objectcache_t
) ( __extension__ ({ static_assert( offsetof(objectcache_it, lock_iobuffer) == offsetof(typeof(*(cache)), lock_iobuffer) && offsetof(objectcache_it, unlock_iobuffer) == offsetof(typeof(*(cache)), unlock_iobuffer), "ensure same structure") ; if (0) { (cache)->lock_iobuffer((objectcache_t*)0, (struct memblock_t**)0) ; (cache)->unlock_iobuffer((objectcache_t*)0, (struct memblock_t**)0) ; } (objectcache_it*) (cache) ; }))
Implements objectcache_it.genericcast_objectcacheit.
#define objectcache_it_DECLARE(
   declared_it,
   objectcache_t
) typedef struct declared_it declared_it ; struct declared_it { void (*lock_iobuffer) (objectcache_t * cache, /*out*/struct memblock_t ** iobuffer); void (*unlock_iobuffer) (objectcache_t * cache, struct memblock_t ** iobuffer) ; }
Implements objectcache_it.objectcache_it_DECLARE.
struct objectcache_impl_t
Holds pointers to all cached objects.
Close