Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
jobs.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2009-2010, 2014 johannes hanika.
4 Copyright (C) 2010 Henrik Andersson.
5 Copyright (C) 2012 Richard Wonka.
6 Copyright (C) 2014, 2016 Tobias Ellinghaus.
7 Copyright (C) 2015 Bruce Guenter.
8 Copyright (C) 2015-2016 Roman Lebedev.
9 Copyright (C) 2019 Edgardo Hoszowski.
10 Copyright (C) 2020 Hanno Schwalm.
11 Copyright (C) 2020 Pascal Obry.
12 Copyright (C) 2022, 2025-2026 Aurélien PIERRE.
13 Copyright (C) 2022 Martin Bařinka.
14 Copyright (C) 2026 Guillaume Stutin.
15
16 darktable is free software: you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation, either version 3 of the License, or
19 (at your option) any later version.
20
21 darktable is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
25
26 You should have received a copy of the GNU General Public License
27 along with darktable. If not, see <http://www.gnu.org/licenses/>.
28*/
29
30#ifndef DT_CONTROL_JOBS_H
31#define DT_CONTROL_JOBS_H
32
33#include <glib.h>
34#include <inttypes.h>
35#include <stddef.h>
36
37#define DT_CONTROL_DESCRIPTION_LEN 256
38// reserved workers
39#define DT_CTL_WORKER_RESERVED 1
40#define DT_CTL_WORKER_DARKROOM 0 // dev zoom 1
41
52
53typedef enum dt_job_queue_t
54{
55 DT_JOB_QUEUE_USER_FG = 0, // gui actions, ...
56 DT_JOB_QUEUE_SYSTEM_FG = 1, // thumbnail creation, ..., may be pushed out of the queue
57 DT_JOB_QUEUE_USER_BG = 2, // imports, ...
58 DT_JOB_QUEUE_USER_EXPORT = 3, // exports. only one of these jobs will ever be scheduled at a time
59 DT_JOB_QUEUE_SYSTEM_BG = 4, // some lua stuff that may not be pushed out of the queue, ...
62
63typedef struct _dt_job_t dt_job_t;
64
65typedef int32_t (*dt_job_execute_callback)(dt_job_t *);
67typedef void (*dt_job_destroy_callback)(void *data);
68
70dt_job_t *dt_control_job_create(dt_job_execute_callback execute, const char *msg, ...) __attribute__((format(printf, 2, 3)));
87void *dt_control_job_get_params(const dt_job_t *job);
88
89void dt_control_job_add_progress(dt_job_t *job, const char *message, gboolean cancellable);
90void dt_control_job_set_progress_message(dt_job_t *job, const char *message);
93
94struct dt_control_t;
95void dt_control_jobs_init(struct dt_control_t *control);
96// Cancel/dispose every still-queued job and empty the queues. MUST run while the modules that
97// own job callbacks (state_changed_cb, params_destroy) are still loaded -- call it from
98// dt_control_shutdown(), after the worker threads are joined but before dt_lib_cleanup() unloads
99// the plug-in .so files. Otherwise a leftover job disposed at the very end (dt_control_jobs_cleanup)
100// fires a callback into an unmapped library -> SIGSEGV.
101void dt_control_jobs_drain(struct dt_control_t *control);
102void dt_control_jobs_cleanup(struct dt_control_t *control);
103
109int32_t dt_control_workers_alive(void);
110
115 gboolean reserved, void *data);
116
122 dt_control_running_jobs_foreach_callback_t callback, void *data);
123
126int32_t dt_control_queued_jobs_count(struct dt_control_t *control);
127
128int dt_control_add_job(struct dt_control_t *control, dt_job_queue_t queue_id, dt_job_t *job);
129int32_t dt_control_add_job_res(struct dt_control_t *s, dt_job_t *job, int32_t res);
130
132
133// Flush all non-running jobs queued in the queue matching the ID
134void dt_control_flush_jobs_queue(struct dt_control_t *control, dt_job_queue_t queue_id);
135
136/* No trailing include of the per-subsystem job headers here: each of them includes this
137 * header back (for dt_job_t), which formed a 5-node include cycle. Consumers of a
138 * specific job factory include the matching control/jobs header explicitly. */
139
140#endif // DT_CONTROL_JOBS_H
141
142// clang-format off
143// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
144// vim: shiftwidth=2 expandtab tabstop=2 cindent
145// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
146// clang-format on
const char ** description(struct dt_iop_module_t *self)
Definition ashift.c:168
size_t params_size(dt_imageio_module_format_t *self)
Definition avif.c:571
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
const int res
Definition dtpthread.h:351
int dt_control_add_job(struct dt_control_t *control, dt_job_queue_t queue_id, dt_job_t *job)
Definition jobs.c:419
dt_job_t void dt_control_job_dispose(dt_job_t *job)
Definition jobs.c:156
void dt_control_job_set_state_callback(dt_job_t *job, dt_job_state_change_callback cb)
Definition jobs.c:168
int32_t dt_control_add_job_res(struct dt_control_t *s, dt_job_t *job, int32_t res)
Definition jobs.c:363
void(* dt_job_state_change_callback)(dt_job_t *, dt_job_state_t state)
Definition jobs.h:66
dt_job_t * dt_control_job_create(dt_job_execute_callback execute, const char *msg,...) __attribute__((format(printf
double dt_control_job_get_progress(dt_job_t *job)
Definition jobs.c:707
void dt_control_job_cancel(dt_job_t *job)
Definition jobs.c:183
void dt_control_job_set_progress(dt_job_t *job, double value)
Definition jobs.c:701
dt_job_queue_t
Definition jobs.h:54
@ DT_JOB_QUEUE_USER_FG
Definition jobs.h:55
@ DT_JOB_QUEUE_MAX
Definition jobs.h:60
@ DT_JOB_QUEUE_USER_BG
Definition jobs.h:57
@ DT_JOB_QUEUE_USER_EXPORT
Definition jobs.h:58
@ DT_JOB_QUEUE_SYSTEM_BG
Definition jobs.h:59
@ DT_JOB_QUEUE_SYSTEM_FG
Definition jobs.h:56
int32_t dt_control_queued_jobs_count(struct dt_control_t *control)
Definition jobs.c:571
int32_t(* dt_job_execute_callback)(dt_job_t *)
Definition jobs.h:65
void dt_control_job_add_progress(dt_job_t *job, const char *message, gboolean cancellable)
Definition jobs.c:687
void dt_control_job_set_progress_message(dt_job_t *job, const char *message)
Definition jobs.c:695
void(* dt_job_destroy_callback)(void *data)
Definition jobs.h:67
void dt_control_jobs_drain(struct dt_control_t *control)
Definition jobs.c:748
void dt_control_jobs_cleanup(struct dt_control_t *control)
Definition jobs.c:771
void dt_control_job_wait(dt_job_t *job)
Definition jobs.c:188
void dt_control_job_set_params_with_size(dt_job_t *job, void *params, size_t params_size, dt_job_destroy_callback callback)
Definition jobs.c:123
void dt_control_running_jobs_foreach(struct dt_control_t *control, dt_control_running_jobs_foreach_callback_t callback, void *data)
Definition jobs.c:549
void dt_control_job_set_params(dt_job_t *job, void *params, dt_job_destroy_callback callback)
Definition jobs.c:115
int32_t dt_control_get_threadid()
Definition jobs.c:586
void(* dt_control_running_jobs_foreach_callback_t)(const char *description, dt_job_queue_t queue, gboolean reserved, void *data)
Definition jobs.h:114
void dt_control_jobs_init(struct dt_control_t *control)
Definition jobs.c:715
int32_t dt_control_workers_alive(void)
Definition jobs.c:544
void * dt_control_job_get_params(const dt_job_t *job)
Definition jobs.c:132
void dt_control_flush_jobs_queue(struct dt_control_t *control, dt_job_queue_t queue_id)
Definition jobs.c:398
dt_job_state_t
Definition jobs.h:43
@ DT_JOB_STATE_DISCARDED
Definition jobs.h:49
@ DT_JOB_STATE_INITIALIZED
Definition jobs.h:44
@ DT_JOB_STATE_DISPOSED
Definition jobs.h:50
@ DT_JOB_STATE_RUNNING
Definition jobs.h:46
@ DT_JOB_STATE_CANCELLED
Definition jobs.h:48
@ DT_JOB_STATE_FINISHED
Definition jobs.h:47
@ DT_JOB_STATE_QUEUED
Definition jobs.h:45
dt_job_state_t dt_control_job_get_state(dt_job_t *job)
Definition jobs.c:106
static const dt_iop_drawlayer_params_t * params
Definition layers.h:80
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Apply one channel's tone curve to each of the three colour channels, or pass the channel through unto...
Definition simd.h:55
static const dt_aligned_pixel_simd_t value
Definition simd.h:144
const float uint32_t state[4]
dt_job_queue_t queue
Definition jobs.c:66
dt_job_execute_callback execute
Definition jobs.c:55