![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#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) |
| #define HASH_A 0x0A0A0A0A0A0A0A0Aull |
Definition at line 40 of file test_pipe_cache_auto_destroy.c.
| #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.
|
static |
Definition at line 54 of file test_pipe_cache_auto_destroy.c.
References dt_dev_pixelpipe_cache_get(), HASH_A, L, LINE_BYTES, and TRUE.
Referenced by _flagged_line_goes_with_its_last_holder(), _flagged_line_goes_with_its_release(), and _unflagged_line_outlives_its_release().
Another holder keeps it, out of reach of any retained lookup, and the last release removes it.
Definition at line 76 of file test_pipe_cache_auto_destroy.c.
References _create(), dt_atomic_get_int(), dt_dev_pixelpipe_cache_flag_auto_destroy(), dt_dev_pixelpipe_cache_get_entry(), dt_dev_pixelpipe_cache_ref_count_entry(), dt_dev_pixelpipe_cache_ref_entry_by_hash(), dt_dev_pixelpipe_cache_wrlock_entry(), FALSE, HASH_A, L, dt_pixel_cache_entry_t::refcount, and TRUE.
Referenced by main().
Flagged while held, then released: the release removes it.
Definition at line 65 of file test_pipe_cache_auto_destroy.c.
References _create(), dt_dev_pixelpipe_cache_flag_auto_destroy(), dt_dev_pixelpipe_cache_get_entry(), dt_dev_pixelpipe_cache_ref_count_entry(), dt_dev_pixelpipe_cache_wrlock_entry(), FALSE, HASH_A, and L.
Referenced by main().
Definition at line 42 of file test_pipe_cache_auto_destroy.c.
References dt_dev_pixelpipe_cache_init(), and FALSE.
Referenced by main().
Definition at line 47 of file test_pipe_cache_auto_destroy.c.
References dt_dev_pixelpipe_cache_cleanup().
Referenced by main().
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().
| int main | ( | void | ) |
Definition at line 108 of file test_pipe_cache_auto_destroy.c.
References _flagged_line_goes_with_its_last_holder(), _flagged_line_goes_with_its_release(), _setup(), _teardown(), _unflagged_line_outlives_its_release(), and L.