Debian Codegraph @

src/dex-thread-pool.h

raw symbols SCIP
1 /* dex-thread-pool.h
2 *
3 * Copyright 2026 Christian Hergert <[email protected]>
4 *
5 * This library is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation; either version 2.1 of the
8 * License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * SPDX-License-Identifier: LGPL-2.1-or-later
19 */
20
21 #pragma once
22
23 #if !defined (DEX_INSIDE) && !defined (DEX_COMPILATION)
24 # error "Only <libdex.h> can be included directly."
25 #endif
26
27 #include "dex-future.h"
28 #include "dex-thread.h"
29 #include "dex-version-macros.h"
30
31 G_BEGIN_DECLS
32
33 #define DEX_TYPE_THREAD_POOL (dex_thread_pool_get_type())
34 #define DEX_THREAD_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, DEX_TYPE_THREAD_POOL, DexThreadPool))
35 #define DEX_IS_THREAD_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, DEX_TYPE_THREAD_POOL))
36
37 typedef struct _DexThreadPool DexThreadPool;
38
39 typedef enum
40 {
41 DEX_THREAD_POOL_SHUTDOWN_DRAIN,
42 DEX_THREAD_POOL_SHUTDOWN_CANCEL_QUEUED,
43 } DexThreadPoolShutdownMode;
44
45 DEX_AVAILABLE_IN_1_2
46 GType dex_thread_pool_get_type (void);
47 DEX_AVAILABLE_IN_1_2
48 DexThreadPool *dex_thread_pool_new (guint n_threads);
49 DEX_AVAILABLE_IN_1_2
50 guint dex_thread_pool_get_n_threads (DexThreadPool *pool);
51 DEX_AVAILABLE_IN_1_2
52 DexFuture *dex_thread_pool_submit (DexThreadPool *pool,
53 const char *thread_name,
54 DexThreadFunc thread_func,
55 gpointer user_data,
56 GDestroyNotify user_data_destroy) G_GNUC_WARN_UNUSED_RESULT;
57 DEX_AVAILABLE_IN_1_2
58 DexFuture *dex_thread_pool_close (DexThreadPool *pool,
59 DexThreadPoolShutdownMode mode) G_GNUC_WARN_UNUSED_RESULT;
60
61 G_DEFINE_AUTOPTR_CLEANUP_FUNC (DexThreadPool, dex_unref)
62
63 G_END_DECLS