GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> QSD / V0-4-5 > qsu / rhel5-32
#include <QSD/QFC_cache.h>
#include <QSD/QFC_file.h>
#include <QSD/QFC_subscription.h>
#include <QFC_memberDef.h>
#include <PBS/Q.ih>
Classes | |
struct | _QFC_cache |
File cache. More... | |
Defines | |
#define | NULL ((void *)0) |
Typedefs | |
typedef struct _QFC_cache | QFC_cache |
Typedef for struct _QFC_cache. | |
Functions | |
static __inline int | qfc_invalidate (QFC_member *member) |
static void | notify_remove (QFC_cache *cache, QFC_member *member) |
Notifies the subscribers of the cache that the specified member is being removed. | |
static void | notify_replace (QFC_cache *cache, QFC_member *new, QFC_member *old) |
Notifies the subscribers of the cache that the specified member is being replaced. | |
int | QFC_sizeof (int nmembers) |
Returns the size, in bytes, of a cache needed to hold nmembers. | |
void * | QFC_construct (QFC_cache *cache, int nmembers) |
Constructs a cache with nmembers. | |
void | QFC_destruct (QFC_cache *cache) |
Destroys the cache. All subscribers are notified. | |
QFC_member * | QFC_findByKey (QFC_cache *cache, unsigned int key) |
Locates the cache member by its key. | |
int | QFC_validate (const QFC_cache *cache, const QFC_member *member, unsigned int key) |
Validates the member. | |
QFC_member * | QFC_add (QFC_cache *cache, unsigned int key, const char *name, void *handle) |
Adds the file to the cache. If the cache is full, the oldest member is removed. Subscribers will be notified on the replacement and posible removal. | |
int | QFC_remove (QFC_cache *cache, QFC_member *member) |
Removes the member from the cache. Subscribers will be notified. | |
int | QFC_removeByKey (QFC_cache *cache, unsigned int key) |
Removes the member from the cache be key. | |
void | QFC_subscribe (QFC_cache *cache, QFC_subscription *subscription) |
Adds a subscription to the cache. The subscriber will be notified on member removal and replacement. | |
void | QFC_unsubscribe (QFC_cache *cache, QFC_subscription *subscription) |
Removes a subscription to the cache. | |
int | QFC_resolve (QFC_cache *cache, QFR_fileCtx *ctx, QFC_file *file, unsigned int key, const char *dirName, const char *fileName, QFR_resolver resolver) |
CVS $Id: QFC_cache.c,v 1.4 2011/03/26 21:06:58 russell Exp $
static void notify_remove | ( | QFC_cache * | cache, | |
QFC_member * | member | |||
) | [static] |
Notifies the subscribers of the cache that the specified member is being removed.
cache | The cache | |
member | The member being removed |
References _QFC_subscription::node, _QFC_subscription::prm, _QFC_subscription::remove, and _QFC_cache::subscriptions.
Referenced by QFC_add(), and QFC_destruct().
static void notify_replace | ( | QFC_cache * | cache, | |
QFC_member * | new, | |||
QFC_member * | old | |||
) | [static] |
Notifies the subscribers of the cache that the specified member is being replaced.
cache | The cache | |
new | The member being added | |
old | The member being replaced |
References _QFC_subscription::node, _QFC_subscription::prm, _QFC_subscription::replace, and _QFC_cache::subscriptions.
Referenced by QFC_add().
QFC_member * QFC_add | ( | QFC_cache * | cache, | |
unsigned int | key, | |||
const char * | name, | |||
void * | handle | |||
) |
Adds the file to the cache. If the cache is full, the oldest member is removed. Subscribers will be notified on the replacement and posible removal.
cache | The cache | |
key | The file/cache key | |
name | The name of the file. Only the pointer is captured, i.e. the name is not copied | |
handle | A handle (arbitrary) to be associated with the file. This is usually some reference to the opened file or information about it. |
References _QFC_cache::activelist, _QFC_cache::freelist, _QFC_memberSpecific::handle, _QFC_member::key, _QFC_member::name, _QFC_member::node, notify_remove(), notify_replace(), and _QFC_member::spc.
void * QFC_construct | ( | QFC_cache * | cache, | |
int | nmembers | |||
) |
Constructs a cache with nmembers.
cache | The cache to construct. The size of the memory for the cache is normally allocated by QFC_sizeof. | |
nmembers | The number of members in the cache. |
References _QFC_cache::activelist, _QFC_cache::freelist, _QFC_cache::members, _QFC_cache::nmembers, _QFC_member::node, and _QFC_cache::subscriptions.
void QFC_destruct | ( | QFC_cache * | cache | ) |
Destroys the cache. All subscribers are notified.
cache | The cache to destroy |
References _QFC_cache::activelist, _QFC_memberSpecific::handle, _QFC_member::key, notify_remove(), and _QFC_member::spc.
QFC_member * QFC_findByKey | ( | QFC_cache * | cache, | |
unsigned int | key | |||
) |
Locates the cache member by its key.
non-NULL,the | member | |
NULL,member | was not found |
cache | The cache | |
key | The file key |
References _QFC_cache::activelist, _QFC_member::key, and _QFC_member::node.
Referenced by QFC_removeByKey().
int QFC_remove | ( | QFC_cache * | cache, | |
QFC_member * | member | |||
) |
Removes the member from the cache. Subscribers will be notified.
==0,successful | removal | |
==-1,\a | member is not a member of the cache |
cache | The cache | |
member | The member to remove |
References _QFC_cache::freelist, _QFC_cache::members, _QFC_cache::nmembers, and _QFC_member::node.
Referenced by QFC_removeByKey().
int QFC_removeByKey | ( | QFC_cache * | cache, | |
unsigned int | key | |||
) |
Removes the member from the cache be key.
==0,successful | removal | |
==-1,\a | member is not a member of the cache |
cache | The cache | |
key | The key of member to remove |
References QFC_findByKey(), and QFC_remove().
int QFC_sizeof | ( | int | nmembers | ) |
Returns the size, in bytes, of a cache needed to hold nmembers.
nmembers | The number of members in the cache |
void QFC_subscribe | ( | QFC_cache * | cache, | |
QFC_subscription * | subscription | |||
) |
Adds a subscription to the cache. The subscriber will be notified on member removal and replacement.
cache | The cache | |
subscription | The subscripion. |
References _QFC_subscription::node, and _QFC_cache::subscriptions.
void QFC_unsubscribe | ( | QFC_cache * | cache, | |
QFC_subscription * | subscription | |||
) |
Removes a subscription to the cache.
cache | The cache | |
subscription | The subscripion. |
References _QFC_subscription::node.
int QFC_validate | ( | const QFC_cache * | cache, | |
const QFC_member * | member, | |||
unsigned int | key | |||
) |
Validates the member.
!=0,member | is valid | |
==0,member | is invalid |
References _QFC_member::key.