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