GStaticPrivate: implement via GPrivate
[platform/upstream/glib.git] / glib / gthreadprivate.h
1 /* GLIB - Library of useful routines for C programming
2  *
3  * gthreadprivate.h - GLib internal thread system related declarations.
4  *
5  *  Copyright (C) 2003 Sebastian Wilhelmi
6  *
7  * The Gnome Library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or (at your option) any later version.
11  *
12  * The Gnome Library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with the Gnome Library; see the file COPYING.LIB.  If not,
19  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  *   Boston, MA 02111-1307, USA.
21  */
22
23 #ifndef __G_THREADPRIVATE_H__
24 #define __G_THREADPRIVATE_H__
25
26 #include "deprecated/gthread.h"
27 #include "garray.h"
28 #include "gslist.h"
29
30 G_BEGIN_DECLS
31
32 /* System thread identifier comparison and assignment */
33 #if GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P
34 # define g_system_thread_assign(dest, src)                              \
35    ((dest).dummy_pointer = (src).dummy_pointer)
36 #else /* GLIB_SIZEOF_SYSTEM_THREAD != SIZEOF_VOID_P */
37 # define g_system_thread_assign(dest, src)                              \
38    (memcpy (&(dest), &(src), GLIB_SIZEOF_SYSTEM_THREAD))
39 #endif /* GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P */
40
41 G_GNUC_INTERNAL void     g_system_thread_self  (gpointer thread);
42 G_GNUC_INTERNAL void     g_system_thread_join  (gpointer thread);
43 G_GNUC_INTERNAL void     g_system_thread_create (GThreadFunc       func,
44                                                  gpointer          data,
45                                                  gulong            stack_size,
46                                                  gboolean          joinable,
47                                                  gpointer          thread,
48                                                  GError          **error);
49 G_GNUC_INTERNAL gboolean g_system_thread_equal (gpointer thread1,
50                                                 gpointer thread2);
51
52 G_GNUC_INTERNAL void     g_system_thread_exit  (void);
53 G_GNUC_INTERNAL void     g_system_thread_set_name (const gchar *name);
54
55 G_GNUC_INTERNAL GThread *g_thread_new_internal (const gchar  *name,
56                                                 GThreadFunc   func,
57                                                 gpointer      data,
58                                                 gboolean      joinable,
59                                                 gsize         stack_size,
60                                                 gboolean      enumerable,
61                                                 GError      **error);
62
63 typedef struct _GRealThread GRealThread;
64 struct  _GRealThread
65 {
66   GThread thread;
67   GRealThread *next;
68   const gchar *name;
69   gboolean enumerable;
70   gpointer retval;
71   GSystemThread system_thread;
72 };
73
74 G_GNUC_INTERNAL extern GSystemThread zero_thread;
75 G_GNUC_INTERNAL extern GMutex g_once_mutex;
76
77 G_GNUC_INTERNAL void g_enumerable_thread_add    (GRealThread *thread);
78 G_GNUC_INTERNAL void g_enumerable_thread_remove (GRealThread *thread);
79
80 /* initializers that may also use g_private_new() */
81 G_GNUC_INTERNAL void _g_messages_thread_init_nomessage      (void);
82
83 #ifdef G_OS_WIN32
84 G_GNUC_INTERNAL void g_thread_DllMain (void);
85 #endif
86
87 G_END_DECLS
88
89 #endif /* __G_THREADPRIVATE_H__ */