60 f->dev.pipe = &
f->pipe;
61 f->dev.preview_pipe = NULL;
73 f->dev.history = NULL;
87 assert_non_null(item);
100 f->dev.history_end = 3;
109 assert_int_equal(g_list_length(snap.
items), 3);
110 assert_ptr_equal(g_list_nth_data(snap.
items, 0), a);
111 assert_ptr_equal(g_list_nth_data(snap.
items, 1), b);
112 assert_ptr_equal(g_list_nth_data(snap.
items, 2), c);
113 assert_int_equal(
_refs(a), 2);
114 assert_int_equal(
_refs(b), 2);
115 assert_int_equal(
_refs(c), 2);
122 assert_null(snap.
items);
123 assert_int_equal(
_refs(a), 1);
124 assert_int_equal(
_refs(b), 1);
125 assert_int_equal(
_refs(c), 1);
133 f->dev.history_end = 99;
148 assert_int_equal(
_refs(item), 1);
153 assert_ptr_equal(touched, item);
154 assert_int_equal(
_refs(item), 1);
155 assert_ptr_equal(g_list_nth_data(
f->dev.history, 0), item);
169 assert_int_equal(
_refs(original), 2);
174 assert_non_null(clone);
175 assert_ptr_not_equal(clone, original);
176 assert_ptr_equal(g_list_nth_data(
f->dev.history, 0), clone);
177 assert_int_equal(
_refs(clone), 1);
178 assert_int_equal(clone->
hash, original->
hash);
182 assert_ptr_equal(g_list_nth_data(snap.
items, 0), original);
183 assert_int_equal(
_refs(original), 1);
198 f->dev.history_end = 1;
204 assert_int_equal(
_refs(original), 2);
210 assert_int_equal(
_refs(original), 3);
213 assert_ptr_not_equal(clone, original);
218 assert_int_equal(
_refs(clone), 2);
219 assert_int_equal(
_refs(original), 1);
226 assert_int_equal(
_refs(clone), 1);
234 f->dev.history_end = 2;
245 assert_ptr_not_equal(clone, second);
249 assert_int_equal(
_refs(first), 3);
250 assert_int_equal(
_refs(clone), 1);
251 assert_int_equal(
_refs(second), 1);
258 const struct CMUnitTest tests[] = {
267 return cmocka_run_group_tests(tests, NULL, NULL);
int dt_atomic_get_int(dt_atomic_int *var)
static void * dt_atomic_exch_ptr(dt_atomic_ptr *var, void *value)
static void * dt_atomic_get_ptr(const dt_atomic_ptr *var)
static void dt_atomic_set_ptr(dt_atomic_ptr *var, void *value)
void dt_dev_history_snapshot_release(dt_dev_history_snapshot_t *snapshot)
Release every reference a snapshot holds and reset it. Needs no lock.
dt_dev_history_item_t * dt_dev_history_item_create(void)
Allocate a fresh, blank history item with refcount 1.
void dt_dev_free_history_item(gpointer data)
Release a reference to a history item (used as GList free callback).
dt_dev_history_item_t * dt_dev_history_item_ref(dt_dev_history_item_t *item)
Take a reference on a history item. Pair with dt_dev_free_history_item().
void dt_dev_history_snapshot_take(dt_develop_t *dev, dt_dev_history_snapshot_t *snapshot) REQUIRES_SHARED(dev -> history_mutex)
Take a snapshot of dev->history. Caller holds history_mutex (reader suffices).
dt_dev_history_item_t * dt_dev_history_cow_touch(dt_develop_t *dev, dt_dev_history_item_t *hist)
Copy-on-write gate for mutating a history item in place.
static void dt_dev_set_history_hash(dt_develop_t *dev, const uint64_t history_hash)
static int dt_pthread_rwlock_unlock(dt_pthread_rwlock_t *rwlock) RELEASE_GENERIC(rwlock) NO_THREAD_SAFETY_ANALYSIS
static int dt_pthread_rwlock_rdlock(dt_pthread_rwlock_t *rwlock) ACQUIRE_SHARED(rwlock) NO_THREAD_SAFETY_ANALYSIS
static int dt_pthread_rwlock_destroy(dt_pthread_rwlock_t *lock)
static int dt_pthread_rwlock_init(dt_pthread_rwlock_t *lock, const pthread_rwlockattr_t *attr)
const float uint32_t state[4]
unsigned __int64 uint64_t
struct dt_iop_module_t *gboolean enabled
A reference-sharing snapshot of dev->history, for readers that outlive a lock.
struct dt_develop_t * dev
static void _history_end_is_clamped_to_the_list_at_snapshot_time(void **state)
static void _cow_touch_leaves_an_exclusively_owned_item_alone(void **state)
static int _setup(void **state)
static int _teardown(void **state)
static void _a_snapshot_references_every_item_and_releases_them(void **state)
static void _cow_touch_ignores_a_marker_naming_a_different_item(void **state)
static void _cow_touch_repoints_the_pipe_marker_and_balances_every_reference(void **state)
static void _cow_touch_clones_an_item_a_snapshot_is_holding(void **state)
static dt_dev_history_item_t * _append(dt_develop_t *dev, const uint64_t hash)
static int _refs(const dt_dev_history_item_t *item)