1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * gthread.c: thread related functions
5 * Copyright 1998 Sebastian Wilhelmi; University of Karlsruhe
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This 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 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
33 static const char *g_log_domain_gthread = "GThread";
34 static gboolean thread_system_already_initialized = FALSE;
36 #include G_THREAD_SOURCE
38 void g_mutex_init (void);
39 void g_mem_init (void);
40 void g_messages_init (void);
43 g_thread_init(GThreadFunctions* init)
47 if (thread_system_already_initialized)
48 g_error ("the glib thread system may only be initialized once.");
50 thread_system_already_initialized = TRUE;
53 init = &g_thread_functions_for_glib_use_default;
55 g_thread_use_default_impl = FALSE;
57 g_thread_functions_for_glib_use = *init;
59 /* It is important, that g_thread_supported is not set before the
60 thread initialization functions of the different modules are
66 init->mutex_trylock &&
71 init->cond_broadcast &&
73 init->cond_timed_wait &&
79 /* if somebody is calling g_thread_init (), it means that he wants to
80 have thread support, so check this */
84 if (g_thread_use_default_impl)
85 g_error ("Threads are not supported on this platform.");
87 g_error ("The supplied thread function vector is invalid.");
90 /* now call the thread initialization functions of the different
91 glib modules. BTW: order does matter, g_mutex_init MUST be first */
97 /* now we can set g_thread_supported and thus enable all the thread
100 g_thread_supported = TRUE;