backend/filehandlecache.h File Reference


Detailed Description

Filehandle management and caching The number of filehandles a program can held open is usually limited, since we want to support using a less limited number of files and closing/opening for each operation is expensive, we provide a cache to keep the most frequent used files open and gracefully close/recycle unused filehandles.

The filehandlecache defined here protects all operations on the cache with a mutex.

Definition in file filehandlecache.h.

#include "lib/error.h"
#include "lib/mrucache.h"
#include "lib/mutex.h"
#include "backend/filehandle.h"

Include dependency graph for filehandlecache.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  lumiera_filehandlecache_struct

Typedefs

typedef struct
lumiera_filehandlecache_struct 
lumiera_filehandlecache
typedef lumiera_filehandlecache * LumieraFilehandlecache

Functions

void lumiera_filehandlecache_checkin (LumieraFilehandle handle)
 Put a filehandle into the cache Filehandles which are checked in are subject of cache aging and might get destroyed and reused.
LumieraFilehandle lumiera_filehandlecache_checkout (LumieraFilehandle handle)
 Remove a filehandle from cache aging Filehandles which are subject of cache aging must be checked out before they can be used.
void lumiera_filehandlecache_delete (void)
 Delete the filehandle cache.
LumieraFilehandle lumiera_filehandlecache_handle_acquire (LumieraFiledescriptor desc)
 Get a fresh filehandle.
void lumiera_filehandlecache_new (int max_entries)
 Initializes the filehandle cache.


Function Documentation

void lumiera_filehandlecache_new ( int  max_entries  ) 

Initializes the filehandle cache.

Parameters:
max_entries number how much filehandles shall be managed The number of elements the cache can hold is static and should be determined by sysconf (_SC_OPEN_MAX) minus some (big) safety margin.

Definition at line 39 of file filehandlecache.c.

References lumiera_mutex_init().

Here is the call graph for this function:

void lumiera_filehandlecache_delete ( void   ) 

Delete the filehandle cache.

No filehandles in the cache must be locked, this would be a fatal error. The handles are closed automatically.

Definition at line 53 of file filehandlecache.c.

References lumiera_free(), and lumiera_mutex_destroy().

Here is the call graph for this function:

LumieraFilehandle lumiera_filehandlecache_handle_acquire ( LumieraFiledescriptor  desc  ) 

Get a fresh filehandle.

Parameters:
self pointer to the cache
Returns:
the new filehandle

Definition at line 67 of file filehandlecache.c.

References LUMIERA_ERROR_SET_ALERT, lumiera_mrucache_pop(), and LUMIERA_MUTEX_SECTION.

Here is the call graph for this function:

LumieraFilehandle lumiera_filehandlecache_checkout ( LumieraFilehandle  handle  ) 

Remove a filehandle from cache aging Filehandles which are subject of cache aging must be checked out before they can be used.

Parameters:
self the filehandlecache
handle the filehandle to be checked out

Definition at line 102 of file filehandlecache.c.

References lumiera_filehandle_struct::cachenode, lumiera_mrucache_checkout(), LUMIERA_MUTEX_SECTION, and lumiera_filehandle_struct::use_cnt.

Here is the call graph for this function:

void lumiera_filehandlecache_checkin ( LumieraFilehandle  handle  ) 

Put a filehandle into the cache Filehandles which are checked in are subject of cache aging and might get destroyed and reused.

Parameters:
self the filehandlecache
handle the filehandle to be checked in

Definition at line 123 of file filehandlecache.c.

References lumiera_filehandle_struct::cachenode, lumiera_mrucache_checkin(), LUMIERA_MUTEX_SECTION, and lumiera_filehandle_struct::use_cnt.

Here is the call graph for this function:


Generated on Thu Jul 22 00:05:27 2010 for Lumiera by  doxygen 1.5.6