Debian Codegraph @

src/dex-init.c

raw symbols SCIP
1 /* libdex.c
2 *
3 * Copyright 2022 Christian Hergert
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but 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
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * SPDX-License-Identifier: LGPL-2.1-or-later
20 */
21
22 #include "config.h"
23
24 #include "libdex.h"
25
26 #include "dex-main-scheduler-private.h"
27 #include "dex-infinite-private.h"
28 #include "dex-scheduler-private.h"
29 #include "dex-semaphore-private.h"
30 #include "dex-state-machine.h"
31 #include "dex-task-group.h"
32 #include "dex-thread-pool-worker-private.h"
33 #include "dex-waiter-private.h"
34
35 #ifdef HAVE_LIBURING
36 # include "dex-uring-future-private.h"
37 #endif
38
39 static void
40 dex_init_once (void)
41 {
42 DexMainScheduler *main_scheduler;
43
44 (void)dex_error_quark ();
45
46 /* Base object, always register first */
47 g_type_ensure (DEX_TYPE_OBJECT);
48
49 /* Scheduler type */
50 g_type_ensure (DEX_TYPE_SCHEDULER);
51 g_type_ensure (DEX_TYPE_MAIN_SCHEDULER);
52 g_type_ensure (DEX_TYPE_THREAD_POOL_SCHEDULER);
53 g_type_ensure (DEX_TYPE_THREAD_POOL_WORKER);
54
55 /* Thread Pool */
56 g_type_ensure (DEX_TYPE_THREAD_POOL);
57
58 /* Future types */
59 g_type_ensure (DEX_TYPE_FUTURE);
60 g_type_ensure (DEX_TYPE_ASYNC_PAIR);
61 g_type_ensure (DEX_TYPE_FIBER);
62 g_type_ensure (DEX_TYPE_COROUTINE);
63 g_type_ensure (DEX_TYPE_FUTURE_SET);
64 g_type_ensure (DEX_TYPE_BLOCK);
65 g_type_ensure (DEX_TYPE_CANCELLABLE);
66 g_type_ensure (DEX_TYPE_PROMISE);
67 g_type_ensure (DEX_TYPE_STATIC_FUTURE);
68 g_type_ensure (DEX_TYPE_TASK_GROUP);
69 g_type_ensure (DEX_TYPE_TIMEOUT);
70 g_type_ensure (DEX_TYPE_INFINITE);
71 #ifdef G_OS_UNIX
72 g_type_ensure (DEX_TYPE_UNIX_SIGNAL);
73 #endif
74 #ifdef HAVE_LIBURING
75 g_type_ensure (DEX_TYPE_URING_FUTURE);
76 #endif
77 g_type_ensure (DEX_TYPE_WAITER);
78
79 /* Misc types */
80 g_type_ensure (DEX_TYPE_ASYNC_RESULT);
81 g_type_ensure (DEX_TYPE_CHANNEL);
82 g_type_ensure (DEX_TYPE_LIMITER);
83 g_type_ensure (DEX_TYPE_SEMAPHORE);
84 g_type_ensure (DEX_TYPE_STATE_MACHINE);
85
86 /* Setup default scheduler for application */
87 main_scheduler = dex_main_scheduler_new (NULL);
88 dex_scheduler_set_default (DEX_SCHEDULER (main_scheduler));
89 }
90
91 void
92 dex_init (void)
93 {
94 static gsize initialized;
95
96 if (g_once_init_enter (&initialized))
97 {
98 dex_init_once ();
99 g_once_init_leave (&initialized, TRUE);
100 }
101 }