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