Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
test_pipe_cache_auto_destroy.c File Reference
#include "caches/pixelpipe_cache.h"
#include "system/atomic.h"
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <stdint.h>
#include <cmocka.h>
+ Include dependency graph for test_pipe_cache_auto_destroy.c:

Go to the source code of this file.

Macros

#define LINE_BYTES   (256 * 1024)
 
#define HASH_A   0x0A0A0A0A0A0A0A0Aull
 

Functions

static int _setup (void **state __attribute__((unused)))
 
static int _teardown (void **state __attribute__((unused)))
 
static dt_pixel_cache_entry_t * _create (void)
 
static void _flagged_line_goes_with_its_release (void **state __attribute__((unused)))
 
static void _flagged_line_goes_with_its_last_holder (void **state __attribute__((unused)))
 
static void _unflagged_line_outlives_its_release (void **state __attribute__((unused)))
 
int main (void)
 

Macro Definition Documentation

◆ HASH_A

#define HASH_A   0x0A0A0A0A0A0A0A0Aull

Definition at line 40 of file test_pipe_cache_auto_destroy.c.

◆ LINE_BYTES

#define LINE_BYTES   (256 * 1024)

A disposable cache line goes with its last release, in the same hold of the cache lock.

To drop a line it holds, a caller flags it, then releases it. Releasing first and naming the line afterwards, to remove or to flag it, leaves a window between two holds of the lock in which another thread's eviction can free it, and the second call then works on freed memory.

These tests drive the cache alone, without a pipe: the contract is the cache's.

Definition at line 39 of file test_pipe_cache_auto_destroy.c.

Function Documentation

◆ _create()

◆ _flagged_line_goes_with_its_last_holder()

static void _flagged_line_goes_with_its_last_holder ( void **state   __attribute__(unused))
static

◆ _flagged_line_goes_with_its_release()

static void _flagged_line_goes_with_its_release ( void **state   __attribute__(unused))
static

◆ _setup()

static int _setup ( void **state   __attribute__(unused))
static

Definition at line 42 of file test_pipe_cache_auto_destroy.c.

References dt_dev_pixelpipe_cache_init(), and FALSE.

Referenced by main().

◆ _teardown()

static int _teardown ( void **state   __attribute__(unused))
static

Definition at line 47 of file test_pipe_cache_auto_destroy.c.

References dt_dev_pixelpipe_cache_cleanup().

Referenced by main().

◆ _unflagged_line_outlives_its_release()

static void _unflagged_line_outlives_its_release ( void **state   __attribute__(unused))
static

A line nobody flagged stays after its last release: it is kept for reuse.

Definition at line 96 of file test_pipe_cache_auto_destroy.c.

References _create(), dt_dev_pixelpipe_cache_ref_count_entry(), dt_dev_pixelpipe_cache_ref_entry_by_hash(), dt_dev_pixelpipe_cache_wrlock_entry(), FALSE, HASH_A, and L.

Referenced by main().

◆ main()