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
15 darktable is free software: you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19
20 darktable is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with darktable. If not, see <http://www.gnu.org/licenses/>.
27*/
28
29#ifndef DT_CONTROL_JOBS_H
30#define DT_CONTROL_JOBS_H
31
32#include <glib.h>
33#include <inttypes.h>
34#include <stddef.h>
35
36#define DT_CONTROL_DESCRIPTION_LEN 256
37// reserved workers
38#define DT_CTL_WORKER_RESERVED 1
39#define DT_CTL_WORKER_DARKROOM 0 // dev zoom 1
40
51
52typedef enum dt_job_queue_t
53{
54 DT_JOB_QUEUE_USER_FG = 0, // gui actions, ...
55 DT_JOB_QUEUE_SYSTEM_FG = 1, // thumbnail creation, ..., may be pushed out of the queue
56 DT_JOB_QUEUE_USER_BG = 2, // imports, ...
57 DT_JOB_QUEUE_USER_EXPORT = 3, // exports. only one of these jobs will ever be scheduled at a time
58 DT_JOB_QUEUE_SYSTEM_BG = 4, // some lua stuff that may not be pushed out of the queue, ...
61
62typedef struct _dt_job_t dt_job_t;
63
64typedef int32_t (*dt_job_execute_callback)(dt_job_t *);
66typedef void (*dt_job_destroy_callback)(void *data);
67
69dt_job_t *dt_control_job_create(dt_job_execute_callback execute, const char *msg, ...) __attribute__((format(printf, 2, 3)));
86void *dt_control_job_get_params(const dt_job_t *job);
87
88void dt_control_job_add_progress(dt_job_t *job, const char *message, gboolean cancellable);
89void dt_control_job_set_progress_message(dt_job_t *job, const char *message);
92
93struct dt_control_t;
94void dt_control_jobs_init(struct dt_control_t *control);
95// Cancel/dispose every still-queued job and empty the queues. MUST run while the modules that
96// own job callbacks (state_changed_cb, params_destroy) are still loaded -- call it from
97// dt_control_shutdown(), after the worker threads are joined but before dt_lib_cleanup() unloads
98// the plug-in .so files. Otherwise a leftover job disposed at the very end (dt_control_jobs_cleanup)
99// fires a callback into an unmapped library -> SIGSEGV.
100void dt_control_jobs_drain(struct dt_control_t *control);
101void dt_control_jobs_cleanup(struct dt_control_t *control);
102
103int dt_control_add_job(struct dt_control_t *control, dt_job_queue_t queue_id, dt_job_t *job);
104int32_t dt_control_add_job_res(struct dt_control_t *s, dt_job_t *job, int32_t res);
105
107
108// Flush all non-running jobs queued in the queue matching the ID
109void dt_control_flush_jobs_queue(struct dt_control_t *control, dt_job_queue_t queue_id);
110
111/* No trailing include of the per-subsystem job headers here: each of them includes this
112 * header back (for dt_job_t), which formed a 5-node include cycle. Consumers of a
113 * specific job factory include the matching control/jobs header explicitly. */
114
115#endif // DT_CONTROL_JOBS_H
116
117// clang-format off
118// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
119// vim: shiftwidth=2 expandtab tabstop=2 cindent
120// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
121// clang-format on
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:407
dt_job_t void dt_control_job_dispose(dt_job_t *job)
Definition jobs.c:155
void dt_control_job_set_state_callback(dt_job_t *job, dt_job_state_change_callback cb)
Definition jobs.c:167
int32_t dt_control_add_job_res(struct dt_control_t *s, dt_job_t *job, int32_t res)
Definition jobs.c:351
void(* dt_job_state_change_callback)(dt_job_t *, dt_job_state_t state)
Definition jobs.h:65
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:634
void dt_control_job_cancel(dt_job_t *job)
Definition jobs.c:182
void dt_control_job_set_progress(dt_job_t *job, double value)
Definition jobs.c:628
dt_job_queue_t
Definition jobs.h:53
@ DT_JOB_QUEUE_USER_FG
Definition jobs.h:54
@ DT_JOB_QUEUE_MAX
Definition jobs.h:59
@ DT_JOB_QUEUE_USER_BG
Definition jobs.h:56
@ DT_JOB_QUEUE_USER_EXPORT
Definition jobs.h:57
@ DT_JOB_QUEUE_SYSTEM_BG
Definition jobs.h:58
@ DT_JOB_QUEUE_SYSTEM_FG
Definition jobs.h:55
int32_t(* dt_job_execute_callback)(dt_job_t *)
Definition jobs.h:64
void dt_control_job_add_progress(dt_job_t *job, const char *message, gboolean cancellable)
Definition jobs.c:614
void dt_control_job_set_progress_message(dt_job_t *job, const char *message)
Definition jobs.c:622
void(* dt_job_destroy_callback)(void *data)
Definition jobs.h:66
void dt_control_jobs_drain(struct dt_control_t *control)
Definition jobs.c:675
void dt_control_jobs_cleanup(struct dt_control_t *control)
Definition jobs.c:698
void dt_control_job_wait(dt_job_t *job)
Definition jobs.c:187
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:122
void dt_control_job_set_params(dt_job_t *job, void *params, dt_job_destroy_callback callback)
Definition jobs.c:114
int32_t dt_control_get_threadid()
Definition jobs.c:528
void dt_control_jobs_init(struct dt_control_t *control)
Definition jobs.c:642
void * dt_control_job_get_params(const dt_job_t *job)
Definition jobs.c:131
void dt_control_flush_jobs_queue(struct dt_control_t *control, dt_job_queue_t queue_id)
Definition jobs.c:386
dt_job_state_t
Definition jobs.h:42
@ DT_JOB_STATE_DISCARDED
Definition jobs.h:48
@ DT_JOB_STATE_INITIALIZED
Definition jobs.h:43
@ DT_JOB_STATE_DISPOSED
Definition jobs.h:49
@ DT_JOB_STATE_RUNNING
Definition jobs.h:45
@ DT_JOB_STATE_CANCELLED
Definition jobs.h:47
@ DT_JOB_STATE_FINISHED
Definition jobs.h:46
@ DT_JOB_STATE_QUEUED
Definition jobs.h:44
dt_job_state_t dt_control_job_get_state(dt_job_t *job)
Definition jobs.c:105
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]
void * params
Definition jobs.c:55
dt_job_execute_callback execute
Definition jobs.c:54