Imported Upstream version 2.74.3
[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  * SPDX-License-Identifier: LGPL-2.1-or-later
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this library; if not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #ifndef __G_THREADPRIVATE_H__
24 #define __G_THREADPRIVATE_H__
25
26 #include "config.h"
27
28 #include "deprecated/gthread.h"
29
30 typedef struct _GRealThread GRealThread;
31 struct  _GRealThread
32 {
33   GThread thread;
34
35   gint ref_count;
36   gboolean ours;
37   gchar *name;
38   gpointer retval;
39 };
40
41 /* system thread implementation (gthread-posix.c, gthread-win32.c) */
42
43 /* Platform-specific scheduler settings for a thread */
44 typedef struct
45 {
46 #if defined(HAVE_SYS_SCHED_GETATTR)
47   /* This is for modern Linux */
48   struct sched_attr *attr;
49 #elif defined(G_OS_WIN32)
50   gint thread_prio;
51 #else
52   /* TODO: Add support for macOS and the BSDs */
53   void *dummy;
54 #endif
55 } GThreadSchedulerSettings;
56
57 void            g_system_thread_wait            (GRealThread  *thread);
58
59 GRealThread *g_system_thread_new (GThreadFunc proxy,
60                                   gulong stack_size,
61                                   const GThreadSchedulerSettings *scheduler_settings,
62                                   const char *name,
63                                   GThreadFunc func,
64                                   gpointer data,
65                                   GError **error);
66 void            g_system_thread_free            (GRealThread  *thread);
67
68 void            g_system_thread_exit            (void);
69 void            g_system_thread_set_name        (const gchar  *name);
70
71 gboolean        g_system_thread_get_scheduler_settings (GThreadSchedulerSettings *scheduler_settings);
72
73 /* gthread.c */
74 GThread *g_thread_new_internal (const gchar *name,
75                                 GThreadFunc proxy,
76                                 GThreadFunc func,
77                                 gpointer data,
78                                 gsize stack_size,
79                                 const GThreadSchedulerSettings *scheduler_settings,
80                                 GError **error);
81
82 gboolean g_thread_get_scheduler_settings (GThreadSchedulerSettings *scheduler_settings);
83
84 gpointer        g_thread_proxy                  (gpointer      thread);
85
86 guint           g_thread_n_created              (void);
87
88 gpointer        g_private_set_alloc0            (GPrivate       *key,
89                                                  gsize           size);
90
91 #endif /* __G_THREADPRIVATE_H__ */