Move some things to deprecated/gthread.h
[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 /* internal function for fallback static mutex implementation */
100 GMutex* g_static_mutex_get_mutex_impl   (GMutex **mutex);
101
102 GThread* g_thread_create_full  (GThreadFunc            func,
103                                 gpointer               data,
104                                 gulong                 stack_size,
105                                 gboolean               joinable,
106                                 gboolean               bound,
107                                 GThreadPriority        priority,
108                                 GError               **error);
109
110 G_END_DECLS
111
112 #endif /* __G_DEPRECATED_THREAD_H__ */