nfs-ganesha 1.4
|
Generic weak reference package. More...
Go to the source code of this file.
Classes | |
struct | gweakref_ |
Typedefs | |
typedef struct gweakref_ | gweakref_t |
typedef struct gweakref_table_ | gweakref_table_t |
Functions | |
gweakref_table_t * | gweakref_init (uint32_t npart, uint32_t cache_sz) |
Create a weak reference table. | |
gweakref_t | gweakref_insert (gweakref_table_t *wt, void *obj) |
Insert a pointer into the weakref table. | |
void * | gweakref_lookup (gweakref_table_t *wt, gweakref_t *ref) |
Wrapper around gweakref_lookupex. | |
void * | gweakref_lookupex (gweakref_table_t *wt, gweakref_t *ref, pthread_rwlock_t **lock) |
Search the table for an entry. | |
void | gweakref_delete (gweakref_table_t *wt, gweakref_t *ref) |
Delete an entry from the table. | |
void | gweakref_destroy (gweakref_table_t *wt) |
Destroy a weakref table. |
Generic weak reference package.
This module defines an infrastructure for enforcement of reference counting guarantees, eviction safety, and access restrictions using ordinary object addresses.
Definition in file generic_weakref.h.
typedef struct gweakref_ gweakref_t |
typedef struct gweakref_table_ gweakref_table_t |
Definition at line 53 of file generic_weakref.h.
void gweakref_delete | ( | gweakref_table_t * | wt, |
gweakref_t * | ref | ||
) |
Delete an entry from the table.
This function deletes and frees the given entry from the weakref table.
wt | [in,out] The table from which to delete the entry |
ref | [in] The entry to delete |
Definition at line 415 of file generic_weakref.c.
void gweakref_destroy | ( | gweakref_table_t * | wt | ) |
Destroy a weakref table.
This function frees all entries in a weakref table, then all partition subtrees.
wt | [in,out] The table to be freed |
Definition at line 429 of file generic_weakref.c.
gweakref_table_t* gweakref_init | ( | uint32_t | npart, |
uint32_t | cache_sz | ||
) |
Create a weak reference table.
This function creates a new, empty weak reference table possessing the specified number of partitions. This table must be freed with gweakref_destroy rather than simply deallocated.
npart | [in] The number of partitions for the table |
Definition at line 189 of file generic_weakref.c.
gweakref_t gweakref_insert | ( | gweakref_table_t * | wt, |
void * | obj | ||
) |
Insert a pointer into the weakref table.
This function inserts a pointer into the weak reference table and returns a weak reference, consisting of a poitner and generation number. If the given pointer already exists within the table, a weak reference consisting of the address NULL and the generation number 0 is returned.
wt | [in] The table in which to add the pointer |
obj | [in] The address to insert |
Definition at line 242 of file generic_weakref.c.
void* gweakref_lookup | ( | gweakref_table_t * | wt, |
gweakref_t * | ref | ||
) |
Wrapper around gweakref_lookupex.
This function is a wrapper around gweakref_lookupex that frees the tree lock after the call.
wt | [in] The table to search |
ref | [in] The reference to search for |
Definition at line 343 of file generic_weakref.c.
void* gweakref_lookupex | ( | gweakref_table_t * | wt, |
gweakref_t * | ref, | ||
pthread_rwlock_t ** | lock | ||
) |
Search the table for an entry.
This function searches the weakref table for the supplied entry. If the entry is found, it is returned and the partition tree is held read-locked, to be unlocked by the caller. Otherwise NULL is returned and the partition tree is unlocked.
wt | [in] The table to search |
ref | [in] The reference to search for |
lock | [out] if the object is found, the lock for the tree. |
Definition at line 290 of file generic_weakref.c.