1 | /* GLIB - Library of useful routines for C programming |
2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
3 | * |
4 | * SPDX-License-Identifier: LGPL-2.1-or-later |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Lesser General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2.1 of the License, or (at your option) any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Lesser General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Lesser General Public |
17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
18 | */ |
19 | |
20 | /* |
21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS |
22 | * file for a list of people on the GLib Team. See the ChangeLog |
23 | * files for a list of changes. These files are distributed with |
24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. |
25 | */ |
26 | |
27 | #ifndef __G_DEPRECATED_THREAD_H__ |
28 | #define __G_DEPRECATED_THREAD_H__ |
29 | |
30 | #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) |
31 | #error "Only <glib.h> can be included directly." |
32 | #endif |
33 | |
34 | #include <glib/gthread.h> |
35 | |
36 | G_BEGIN_DECLS |
37 | |
38 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS |
39 | |
40 | typedef enum |
41 | { |
42 | G_THREAD_PRIORITY_LOW, |
43 | G_THREAD_PRIORITY_NORMAL, |
44 | G_THREAD_PRIORITY_HIGH, |
45 | G_THREAD_PRIORITY_URGENT |
46 | } GThreadPriority GLIB_DEPRECATED_TYPE_IN_2_32; |
47 | |
48 | struct _GThread |
49 | { |
50 | /*< private >*/ |
51 | GThreadFunc func; |
52 | gpointer data; |
53 | gboolean joinable; |
54 | GThreadPriority priority; |
55 | }; |
56 | |
57 | typedef struct _GThreadFunctions GThreadFunctions GLIB_DEPRECATED_TYPE_IN_2_32; |
58 | struct _GThreadFunctions |
59 | { |
60 | GMutex* (*mutex_new) (void); |
61 | void (*mutex_lock) (GMutex *mutex); |
62 | gboolean (*mutex_trylock) (GMutex *mutex); |
63 | void (*mutex_unlock) (GMutex *mutex); |
64 | void (*mutex_free) (GMutex *mutex); |
65 | GCond* (*cond_new) (void); |
66 | void (*cond_signal) (GCond *cond); |
67 | void (*cond_broadcast) (GCond *cond); |
68 | void (*cond_wait) (GCond *cond, |
69 | GMutex *mutex); |
70 | gboolean (*cond_timed_wait) (GCond *cond, |
71 | GMutex *mutex, |
72 | GTimeVal *end_time); |
73 | void (*cond_free) (GCond *cond); |
74 | GPrivate* (*private_new) (GDestroyNotify destructor); |
75 | gpointer (*private_get) (GPrivate *private_key); |
76 | void (*private_set) (GPrivate *private_key, |
77 | gpointer data); |
78 | void (*thread_create) (GThreadFunc func, |
79 | gpointer data, |
80 | gulong stack_size, |
81 | gboolean joinable, |
82 | gboolean bound, |
83 | GThreadPriority priority, |
84 | gpointer thread, |
85 | GError **error); |
86 | void (*thread_yield) (void); |
87 | void (*thread_join) (gpointer thread); |
88 | void (*thread_exit) (void); |
89 | void (*thread_set_priority)(gpointer thread, |
90 | GThreadPriority priority); |
91 | void (*thread_self) (gpointer thread); |
92 | gboolean (*thread_equal) (gpointer thread1, |
93 | gpointer thread2); |
94 | } GLIB_DEPRECATED_TYPE_IN_2_32; |
95 | |
96 | GLIB_VAR GThreadFunctions g_thread_functions_for_glib_use; |
97 | GLIB_VAR gboolean g_thread_use_default_impl; |
98 | |
99 | GLIB_VAR guint64 (*g_thread_gettime) (void); |
100 | |
101 | GLIB_DEPRECATED_IN_2_32_FOR(g_thread_new) |
102 | GThread *g_thread_create (GThreadFunc func, |
103 | gpointer data, |
104 | gboolean joinable, |
105 | GError **error); |
106 | |
107 | GLIB_DEPRECATED_IN_2_32_FOR(g_thread_new) |
108 | GThread *g_thread_create_full (GThreadFunc func, |
109 | gpointer data, |
110 | gulong stack_size, |
111 | gboolean joinable, |
112 | gboolean bound, |
113 | GThreadPriority priority, |
114 | GError **error); |
115 | |
116 | GLIB_DEPRECATED_IN_2_32 |
117 | void g_thread_set_priority (GThread *thread, |
118 | GThreadPriority priority); |
119 | |
120 | GLIB_DEPRECATED_IN_2_32 |
121 | void g_thread_foreach (GFunc thread_func, |
122 | gpointer user_data); |
123 | |
124 | #ifndef G_OS_WIN32 |
125 | #include <sys/types.h> |
126 | #include <pthread.h> |
127 | #endif |
128 | |
129 | #define g_static_mutex_get_mutex g_static_mutex_get_mutex_impl GLIB_DEPRECATED_MACRO_IN_2_32 |
130 | #ifndef G_OS_WIN32 |
131 | #define G_STATIC_MUTEX_INIT { NULL, PTHREAD_MUTEX_INITIALIZER } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_init) |
132 | #else |
133 | #define G_STATIC_MUTEX_INIT { NULL } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_init) |
134 | #endif |
135 | typedef struct |
136 | { |
137 | GMutex *mutex; |
138 | #ifndef __GI_SCANNER__ |
139 | # ifndef G_OS_WIN32 |
140 | /* only for ABI compatibility reasons */ |
141 | pthread_mutex_t unused; |
142 | # endif /* !G_OS_WIN32 */ |
143 | #endif /* !__GI_SCANNER__ */ |
144 | } GStaticMutex GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GMutex); |
145 | |
146 | #define g_static_mutex_lock(mutex) \ |
147 | g_mutex_lock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_lock) |
148 | #define g_static_mutex_trylock(mutex) \ |
149 | g_mutex_trylock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_trylock) |
150 | #define g_static_mutex_unlock(mutex) \ |
151 | g_mutex_unlock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_unlock) |
152 | |
153 | GLIB_DEPRECATED_IN_2_32_FOR(g_mutex_init) |
154 | void g_static_mutex_init (GStaticMutex *mutex); |
155 | GLIB_DEPRECATED_IN_2_32_FOR(g_mutex_clear) |
156 | void g_static_mutex_free (GStaticMutex *mutex); |
157 | GLIB_DEPRECATED_IN_2_32_FOR(GMutex) |
158 | GMutex *g_static_mutex_get_mutex_impl (GStaticMutex *mutex); |
159 | |
160 | typedef struct _GStaticRecMutex GStaticRecMutex GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRecMutex); |
161 | struct _GStaticRecMutex |
162 | { |
163 | /*< private >*/ |
164 | GStaticMutex mutex; |
165 | guint depth; |
166 | |
167 | #ifndef __GI_SCANNER__ |
168 | /* ABI compat only */ |
169 | union { |
170 | # ifdef G_OS_WIN32 |
171 | void *owner; |
172 | # else |
173 | pthread_t owner; |
174 | # endif /* !G_OS_WIN32 */ |
175 | gdouble dummy; |
176 | } unused; |
177 | #endif /* !__GI_SCANNER__ */ |
178 | } GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRecMutex); |
179 | |
180 | #define G_STATIC_REC_MUTEX_INIT { G_STATIC_MUTEX_INIT, 0, { 0 } } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_rec_mutex_init) |
181 | GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_init) |
182 | void g_static_rec_mutex_init (GStaticRecMutex *mutex); |
183 | |
184 | GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_lock) |
185 | void g_static_rec_mutex_lock (GStaticRecMutex *mutex); |
186 | |
187 | GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_try_lock) |
188 | gboolean g_static_rec_mutex_trylock (GStaticRecMutex *mutex); |
189 | |
190 | GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_unlock) |
191 | void g_static_rec_mutex_unlock (GStaticRecMutex *mutex); |
192 | |
193 | GLIB_DEPRECATED_IN_2_32 |
194 | void g_static_rec_mutex_lock_full (GStaticRecMutex *mutex, |
195 | guint depth); |
196 | |
197 | GLIB_DEPRECATED_IN_2_32 |
198 | guint g_static_rec_mutex_unlock_full (GStaticRecMutex *mutex); |
199 | |
200 | GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_free) |
201 | void g_static_rec_mutex_free (GStaticRecMutex *mutex); |
202 | |
203 | typedef struct _GStaticRWLock GStaticRWLock GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRWLock); |
204 | struct _GStaticRWLock |
205 | { |
206 | /*< private >*/ |
207 | GStaticMutex mutex; |
208 | GCond *read_cond; |
209 | GCond *write_cond; |
210 | guint read_counter; |
211 | gboolean have_writer; |
212 | guint want_to_read; |
213 | guint want_to_write; |
214 | } GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRWLock); |
215 | |
216 | #define G_STATIC_RW_LOCK_INIT { G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, 0, 0 } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_rw_lock_init) |
217 | |
218 | GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_init) |
219 | void g_static_rw_lock_init (GStaticRWLock *lock); |
220 | |
221 | GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_lock) |
222 | void g_static_rw_lock_reader_lock (GStaticRWLock *lock); |
223 | |
224 | GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_trylock) |
225 | gboolean g_static_rw_lock_reader_trylock (GStaticRWLock *lock); |
226 | |
227 | GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_unlock) |
228 | void g_static_rw_lock_reader_unlock (GStaticRWLock *lock); |
229 | |
230 | GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_lock) |
231 | void g_static_rw_lock_writer_lock (GStaticRWLock *lock); |
232 | |
233 | GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_trylock) |
234 | gboolean g_static_rw_lock_writer_trylock (GStaticRWLock *lock); |
235 | |
236 | GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_unlock) |
237 | void g_static_rw_lock_writer_unlock (GStaticRWLock *lock); |
238 | |
239 | GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_free) |
240 | void g_static_rw_lock_free (GStaticRWLock *lock); |
241 | |
242 | GLIB_DEPRECATED_IN_2_32 |
243 | GPrivate * g_private_new (GDestroyNotify notify); |
244 | |
245 | typedef struct _GStaticPrivate GStaticPrivate GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GPrivate); |
246 | struct _GStaticPrivate |
247 | { |
248 | /*< private >*/ |
249 | guint index; |
250 | } GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GPrivate); |
251 | |
252 | #define G_STATIC_PRIVATE_INIT { 0 } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(G_PRIVATE_INIT) |
253 | GLIB_DEPRECATED_IN_2_32 |
254 | void g_static_private_init (GStaticPrivate *private_key); |
255 | |
256 | GLIB_DEPRECATED_IN_2_32_FOR(g_private_get) |
257 | gpointer g_static_private_get (GStaticPrivate *private_key); |
258 | |
259 | GLIB_DEPRECATED_IN_2_32_FOR(g_private_set) |
260 | void g_static_private_set (GStaticPrivate *private_key, |
261 | gpointer data, |
262 | GDestroyNotify notify); |
263 | |
264 | GLIB_DEPRECATED_IN_2_32 |
265 | void g_static_private_free (GStaticPrivate *private_key); |
266 | |
267 | GLIB_DEPRECATED_IN_2_32 |
268 | gboolean g_once_init_enter_impl (volatile gsize *location); |
269 | |
270 | GLIB_DEPRECATED_IN_2_32 |
271 | void g_thread_init (gpointer vtable); |
272 | GLIB_DEPRECATED_IN_2_32 |
273 | void g_thread_init_with_errorcheck_mutexes (gpointer vtable); |
274 | |
275 | GLIB_DEPRECATED_IN_2_32 |
276 | gboolean g_thread_get_initialized (void); |
277 | |
278 | GLIB_VAR gboolean g_threads_got_initialized; |
279 | |
280 | #define g_thread_supported() (1) GLIB_DEPRECATED_MACRO_IN_2_32 |
281 | |
282 | GLIB_DEPRECATED_IN_2_32 |
283 | GMutex * g_mutex_new (void); |
284 | GLIB_DEPRECATED_IN_2_32 |
285 | void g_mutex_free (GMutex *mutex); |
286 | GLIB_DEPRECATED_IN_2_32 |
287 | GCond * g_cond_new (void); |
288 | GLIB_DEPRECATED_IN_2_32 |
289 | void g_cond_free (GCond *cond); |
290 | GLIB_DEPRECATED_IN_2_32 |
291 | gboolean g_cond_timed_wait (GCond *cond, |
292 | GMutex *mutex, |
293 | GTimeVal *abs_time); |
294 | |
295 | G_GNUC_END_IGNORE_DEPRECATIONS |
296 | |
297 | G_END_DECLS |
298 | |
299 | #endif /* __G_DEPRECATED_THREAD_H__ */ |
300 | |