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 "win/main_wrapper.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 (int argc, char *argv[])

Macro Definition Documentation

◆ HASH_A

◆ 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 43 of file test_pipe_cache_auto_destroy.c.

Referenced by _create(), _create_held(), _produce(), _publish(), _rewritten_line_publishes_its_host_pixels(), and _without_rekey_the_previous_output_stays().

Function Documentation

◆ _create()

◆ _flagged_line_goes_with_its_last_holder()

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

◆ _flagged_line_goes_with_its_release()

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

◆ _setup()

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

Definition at line 46 of file test_pipe_cache_auto_destroy.c.

References dt_dev_pixelpipe_cache_init(), FALSE, and state.

◆ _teardown()

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

Definition at line 51 of file test_pipe_cache_auto_destroy.c.

References dt_dev_pixelpipe_cache_cleanup(), and state.

◆ _unflagged_line_outlives_its_release()

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 100 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 state.

Referenced by main().

◆ main()

int main ( int argc,
char * argv[] )
Todo
: test if file with replaced ext exists
Todo
: add a callback to set the bpp without going through the config
Todo
: have a parameter in command line to get the export presets

Definition at line 112 of file test_pipe_cache_auto_destroy.c.

References _flagged_line_goes_with_its_last_holder(), _flagged_line_goes_with_its_release(), _setup(), _teardown(), and _unflagged_line_outlives_its_release().