Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
pixelpipe_cache_wait.c File Reference
#include "caches/pixelpipe_cache_wait.h"
#include "caches/pixelpipe_cache.h"
#include "system/macros.h"
#include "system/mem_alloc.h"
#include <stdlib.h>
+ Include dependency graph for pixelpipe_cache_wait.c:

Go to the source code of this file.

Data Structures

struct  dt_pixelpipe_cache_wait_record_t
 
struct  dt_pixelpipe_cache_wait_queue_t
 

Typedefs

typedef struct dt_pixelpipe_cache_wait_record_t dt_pixelpipe_cache_wait_record_t
 
typedef struct dt_pixelpipe_cache_wait_queue_t dt_pixelpipe_cache_wait_queue_t
 

Functions

static void _unlink_locked (GList *link)
 
static GList_find_locked (const dt_pixelpipe_cache_wait_t *wait)
 
gboolean dt_pixelpipe_cache_wait_enqueue (dt_pixelpipe_cache_wait_t *wait)
 Queue wait, or refresh it in place if it is already queued for the same target.
 
GListdt_pixelpipe_cache_wait_take_matching (const uint64_t hash, const uint64_t producer_node_key, gboolean *drained)
 Take every waiter satisfied by a publication of hash from node producer_node_key.
 
gboolean dt_pixelpipe_cache_wait_cancel (dt_pixelpipe_cache_wait_t *wait, gboolean *drained)
 Remove wait from the queue if it is there, and reset it to an inert state.
 
guint dt_pixelpipe_cache_wait_pending_count (void)
 How many requests are outstanding. Diagnostics only.
 
void dt_pixelpipe_cache_wait_get_stats (uint64_t *queued, uint64_t *served, uint64_t *cancelled, uint64_t *immediate_hits, uint64_t *misses)
 Snapshot of the lifetime counters, for the dump. Any pointer may be NULL.
 
void dt_pixelpipe_cache_wait_count_immediate_hit (void)
 Count one cache hit that never needed to queue.
 
void dt_pixelpipe_cache_wait_count_miss (void)
 Count one miss that is about to queue.
 
void dt_pixelpipe_cache_wait_foreach_pending (dt_pixelpipe_cache_wait_visitor_t callback, gpointer user_data)
 

Variables

static dt_pixelpipe_cache_wait_queue_t _queue
 

Typedef Documentation

◆ dt_pixelpipe_cache_wait_queue_t

◆ dt_pixelpipe_cache_wait_record_t

Function Documentation

◆ _find_locked()

static GList * _find_locked ( const dt_pixelpipe_cache_wait_t wait)
static

Find the record linking wait, or NULL. Caller holds the lock.

Definition at line 64 of file pixelpipe_cache_wait.c.

References _queue, IS_NULL_PTR, L, and dt_pixelpipe_cache_wait_queue_t::pending.

Referenced by dt_pixelpipe_cache_wait_cancel(), and dt_pixelpipe_cache_wait_enqueue().

◆ _unlink_locked()

static void _unlink_locked ( GList link)
static

Unlink one record without touching the wait it points at. Caller holds the lock.

Definition at line 56 of file pixelpipe_cache_wait.c.

References _queue, dt_free, L, and dt_pixelpipe_cache_wait_queue_t::pending.

Referenced by dt_pixelpipe_cache_wait_cancel(), and dt_pixelpipe_cache_wait_take_matching().

◆ dt_pixelpipe_cache_wait_cancel()

gboolean dt_pixelpipe_cache_wait_cancel ( dt_pixelpipe_cache_wait_t wait,
gboolean *  drained 
)

Remove wait from the queue if it is there, and reset it to an inert state.

Parameters
drainedSet to TRUE when this emptied the queue.
Returns
TRUE when the wait was actually queued and has now been removed.

Definition at line 145 of file pixelpipe_cache_wait.c.

References _find_locked(), _queue, _unlink_locked(), dt_pixelpipe_cache_wait_queue_t::cancelled_requests, dt_pixelpipe_cache_wait_t::connected, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), FALSE, IS_NULL_PTR, L, dt_pixelpipe_cache_wait_queue_t::lock, and dt_pixelpipe_cache_wait_queue_t::pending.

Referenced by dt_dev_pixelpipe_cache_wait_cleanup().

◆ dt_pixelpipe_cache_wait_count_immediate_hit()

void dt_pixelpipe_cache_wait_count_immediate_hit ( void  )

◆ dt_pixelpipe_cache_wait_count_miss()

void dt_pixelpipe_cache_wait_count_miss ( void  )

◆ dt_pixelpipe_cache_wait_enqueue()

gboolean dt_pixelpipe_cache_wait_enqueue ( dt_pixelpipe_cache_wait_t wait)

Queue wait, or refresh it in place if it is already queued for the same target.

Returns
TRUE when the queue went from empty to non-empty, so the caller can raise whatever "the user is waiting" state it owns. FALSE otherwise, including when the wait was already queued unchanged.

Definition at line 74 of file pixelpipe_cache_wait.c.

References _find_locked(), _queue, dt_pixelpipe_cache_wait_t::connected, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), FALSE, IS_NULL_PTR, L, dt_pixelpipe_cache_wait_queue_t::lock, dt_pixelpipe_cache_wait_queue_t::next_request_id, dt_pixelpipe_cache_wait_queue_t::pending, dt_pixelpipe_cache_wait_queue_t::queued_requests, dt_pixelpipe_cache_wait_t::request_id, and TRUE.

Referenced by dt_dev_pixelpipe_cache_peek_gui().

◆ dt_pixelpipe_cache_wait_foreach_pending()

◆ dt_pixelpipe_cache_wait_get_stats()

◆ dt_pixelpipe_cache_wait_pending_count()

guint dt_pixelpipe_cache_wait_pending_count ( void  )

◆ dt_pixelpipe_cache_wait_take_matching()

GList * dt_pixelpipe_cache_wait_take_matching ( uint64_t  hash,
uint64_t  producer_node_key,
gboolean *  drained 
)

Take every waiter satisfied by a publication of hash from node producer_node_key.

Matches on the exact hash OR on the producing node, which is what makes the protocol survive hash drift. Removes them from the queue and marks them disconnected.

Parameters
drainedSet to TRUE when this emptied the queue.
Returns
A caller-owned GList of dt_pixelpipe_cache_wait_t*, to run and then free. Callbacks are deliberately NOT run here: see the file comment on why the caller owns that step.

Definition at line 110 of file pixelpipe_cache_wait.c.

References _queue, _unlink_locked(), dt_pixelpipe_cache_wait_t::connected, DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), FALSE, dt_pixelpipe_cache_wait_t::hash, IS_NULL_PTR, L, dt_pixelpipe_cache_wait_queue_t::lock, dt_pixelpipe_cache_wait_queue_t::pending, dt_pixelpipe_cache_wait_queue_t::served_requests, and dt_pixelpipe_cache_wait_t::target_node_key.

Referenced by _dt_dev_pixelpipe_cache_wait_ready_callback().

Variable Documentation

◆ _queue