clrucache · Section 3
ccache_destroy
NAME
ccache_destroy - destroy an LRU cache and invalidate the handle
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/clrucache.h> ccache_destroy(name);
DESCRIPTION
Waits until every in-flight resolved use of the handle has stopped, then evicts all the remaining entries, calling the eviction callback for each one with the lock of the owning segment held. After that it destroys the map of every segment, frees all the memory and sets name to CCACHE_NULL. This is the name the type-inferred macro layer uses for clrucache_destroy(3). It behaves the same way.
PARAMETERS
name The cache variable to destroy. The macro sets it to
CCACHE_NULL after the destruction
NOTES
Calling it when name is CCACHE_NULL is safe, and it does nothing. A call on a stale handle is a FATAL ERROR: It calls abort() and raises SIGABRT, and it is never a silent double-free. A handle is stale when an earlier call destroyed it, or when another thread destroys it at the same time. A forged value or garbage is a fatal error too. The handle carries a generation tag that the library checks before it touches the cache behind it, so such a value is always detected and never dereferenced. A concurrent, ordinary call to clrucache_get_full(), clrucache_set_full(), clrucache_size() or clrucache_capacity() on the same handle is not misuse; this call waits for that call to finish before it frees anything. The macro evaluates name exactly once. It must be a modifiable lvalue, such as a variable or an element of an array, so with an expression that has a side effect, such as handles[i++], it destroys and clears one element.
SEE ALSO
clrucache_destroy(3), ccache_construct(3), clrucache_create_full(3)