Use GLIB_DEPRECATED instead of G_GNUC_DEPRECATED in our headers
[platform/upstream/glib.git] / glib / deprecated / gthread.h
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 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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
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 #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
28 #error "Only <glib.h> can be included directly."
29 #endif
30
31 #ifndef __G_DEPRECATED_THREAD_H__
32 #define __G_DEPRECATED_THREAD_H__
33
34 #include <glib/gthread.h>
35
36 G_BEGIN_DECLS
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;
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;
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 };
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_FOR(g_thread_new)
100 GThread *g_thread_create       (GThreadFunc       func,
101                                 gpointer          data,
102                                 gboolean          joinable,
103                                 GError          **error);
104
105 GLIB_DEPRECATED_FOR(g_thread_new_full)
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
115 void     g_thread_set_priority (GThread          *thread,
116                                 GThreadPriority   priority);
117
118 GLIB_DEPRECATED
119 void     g_thread_foreach      (GFunc             thread_func,
120                                 gpointer          user_data);
121
122 #ifndef G_OS_WIN32
123 #include <pthread.h>
124 #endif
125
126 #define g_static_mutex_get_mutex g_static_mutex_get_mutex_impl
127 #define G_STATIC_MUTEX_INIT { NULL }
128 typedef struct
129 {
130   GMutex *mutex;
131 #ifndef G_OS_WIN32
132   /* only for ABI compatibility reasons */
133   pthread_mutex_t unused;
134 #endif
135 } GStaticMutex;
136
137 #define g_static_mutex_lock(mutex) \
138     g_mutex_lock (g_static_mutex_get_mutex (mutex))
139 #define g_static_mutex_trylock(mutex) \
140     g_mutex_trylock (g_static_mutex_get_mutex (mutex))
141 #define g_static_mutex_unlock(mutex) \
142     g_mutex_unlock (g_static_mutex_get_mutex (mutex))
143
144 GLIB_DEPRECATED_FOR(g_mutex_init)
145 void    g_static_mutex_init           (GStaticMutex *mutex);
146 GLIB_DEPRECATED_FOR(g_mutex_free)
147 void    g_static_mutex_free           (GStaticMutex *mutex);
148 GMutex *g_static_mutex_get_mutex_impl (GStaticMutex *mutex);
149
150 typedef struct _GStaticRecMutex GStaticRecMutex;
151 struct _GStaticRecMutex
152 {
153   /*< private >*/
154   GStaticMutex mutex;
155   guint depth;
156   GSystemThread owner;
157 };
158
159 #define G_STATIC_REC_MUTEX_INIT { G_STATIC_MUTEX_INIT, 0, {{0, 0, 0, 0}} }
160 GLIB_DEPRECATED_FOR(g_rec_mutex_init)
161 void     g_static_rec_mutex_init        (GStaticRecMutex *mutex);
162
163 GLIB_DEPRECATED_FOR(g_rec_mutex_lock)
164 void     g_static_rec_mutex_lock        (GStaticRecMutex *mutex);
165
166 GLIB_DEPRECATED_FOR(g_rec_mutex_try_lock)
167 gboolean g_static_rec_mutex_trylock     (GStaticRecMutex *mutex);
168
169 GLIB_DEPRECATED_FOR(g_rec_mutex_unlock)
170 void     g_static_rec_mutex_unlock      (GStaticRecMutex *mutex);
171
172 GLIB_DEPRECATED
173 void     g_static_rec_mutex_lock_full   (GStaticRecMutex *mutex,
174                                          guint            depth);
175
176 GLIB_DEPRECATED
177 guint    g_static_rec_mutex_unlock_full (GStaticRecMutex *mutex);
178
179 GLIB_DEPRECATED_FOR(g_rec_mutex_free)
180 void     g_static_rec_mutex_free        (GStaticRecMutex *mutex);
181
182 typedef struct _GStaticRWLock GStaticRWLock;
183 struct _GStaticRWLock
184 {
185   /*< private >*/
186   GStaticMutex mutex;
187   GCond *read_cond;
188   GCond *write_cond;
189   guint read_counter;
190   gboolean have_writer;
191   guint want_to_read;
192   guint want_to_write;
193 };
194
195 #define G_STATIC_RW_LOCK_INIT { G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, 0, 0 }
196
197 GLIB_DEPRECATED_FOR(g_rw_lock_init)
198 void      g_static_rw_lock_init           (GStaticRWLock *lock);
199
200 GLIB_DEPRECATED_FOR(g_rw_lock_reader_lock)
201 void      g_static_rw_lock_reader_lock    (GStaticRWLock *lock);
202
203 GLIB_DEPRECATED_FOR(g_rw_lock_reader_trylock)
204 gboolean  g_static_rw_lock_reader_trylock (GStaticRWLock *lock);
205
206 GLIB_DEPRECATED_FOR(g_rw_lock_reader_unlock)
207 void      g_static_rw_lock_reader_unlock  (GStaticRWLock *lock);
208
209 GLIB_DEPRECATED_FOR(g_rw_lock_writer_lock)
210 void      g_static_rw_lock_writer_lock    (GStaticRWLock *lock);
211
212 GLIB_DEPRECATED_FOR(g_rw_lock_writer_trylock)
213 gboolean  g_static_rw_lock_writer_trylock (GStaticRWLock *lock);
214
215 GLIB_DEPRECATED_FOR(g_rw_lock_writer_unlock)
216 void      g_static_rw_lock_writer_unlock  (GStaticRWLock *lock);
217
218 GLIB_DEPRECATED_FOR(g_rw_lock_free)
219 void      g_static_rw_lock_free           (GStaticRWLock *lock);
220
221 GLIB_DEPRECATED
222 GPrivate *      g_private_new             (GDestroyNotify notify);
223
224 typedef struct _GStaticPrivate  GStaticPrivate;
225 struct _GStaticPrivate
226 {
227   /*< private >*/
228   guint index;
229 };
230
231 #define G_STATIC_PRIVATE_INIT { 0 }
232 GLIB_DEPRECATED
233 void     g_static_private_init           (GStaticPrivate *private_key);
234
235 GLIB_DEPRECATED_FOR(g_private_get)
236 gpointer g_static_private_get            (GStaticPrivate *private_key);
237
238 GLIB_DEPRECATED_FOR(g_private_set)
239 void     g_static_private_set            (GStaticPrivate *private_key,
240                                           gpointer        data,
241                                           GDestroyNotify  notify);
242
243 GLIB_DEPRECATED
244 void     g_static_private_free           (GStaticPrivate *private_key);
245
246 GLIB_DEPRECATED
247 gboolean g_once_init_enter_impl          (volatile gsize *location);
248
249 GLIB_DEPRECATED
250 void     g_thread_init                   (gpointer vtable);
251
252 GLIB_DEPRECATED
253 gboolean g_thread_get_initialized        (void);
254
255 GLIB_VAR gboolean g_threads_got_initialized;
256
257 #if defined(G_THREADS_MANDATORY)
258 #define g_thread_supported()     1
259 #else
260 #define g_thread_supported()    (g_threads_got_initialized)
261 #endif
262
263 GLIB_DEPRECATED
264 GMutex *                g_mutex_new  (void);
265 GLIB_DEPRECATED
266 void                    g_mutex_free (GMutex *mutex) ;
267 GLIB_DEPRECATED
268 GCond *                 g_cond_new   (void);
269 GLIB_DEPRECATED
270 void                    g_cond_free  (GCond  *cond);
271
272 G_END_DECLS
273
274 #endif /* __G_DEPRECATED_THREAD_H__ */