mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-24 19:22:11 +01:00
GSystemThread: port 'self' 'join' and 'create'
Switch 'self' 'join' and 'create' from using the vtable to being called via normal g_system_thread_* internal API (implemented in each of gthread-{posix,win32}.c). Again, we can put NULL in the vtable since these were never used from gthread.h.
This commit is contained in:
parent
51d92adeee
commit
7a69d46dc5
@ -492,8 +492,8 @@ _g_thread_impl_init(void)
|
||||
#endif /* _SC_THREAD_STACK_MIN */
|
||||
}
|
||||
|
||||
static void
|
||||
g_thread_create_posix_impl (GThreadFunc thread_func,
|
||||
void
|
||||
g_system_thread_create (GThreadFunc thread_func,
|
||||
gpointer arg,
|
||||
gulong stack_size,
|
||||
gboolean joinable,
|
||||
@ -558,8 +558,8 @@ g_thread_yield (void)
|
||||
sched_yield ();
|
||||
}
|
||||
|
||||
static void
|
||||
g_thread_join_posix_impl (gpointer thread)
|
||||
void
|
||||
g_system_thread_join (gpointer thread)
|
||||
{
|
||||
gpointer ignore;
|
||||
posix_check_cmd (pthread_join (*(pthread_t*)thread, &ignore));
|
||||
@ -571,8 +571,8 @@ g_system_thread_exit (void)
|
||||
pthread_exit (NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
g_thread_self_posix_impl (gpointer thread)
|
||||
void
|
||||
g_system_thread_self (gpointer thread)
|
||||
{
|
||||
*(pthread_t*)thread = pthread_self();
|
||||
}
|
||||
@ -601,12 +601,12 @@ GThreadFunctions g_thread_functions_for_glib_use =
|
||||
g_private_new,
|
||||
g_private_get,
|
||||
g_private_set,
|
||||
g_thread_create_posix_impl,
|
||||
NULL,
|
||||
g_thread_yield,
|
||||
g_thread_join_posix_impl,
|
||||
NULL,
|
||||
g_system_thread_exit,
|
||||
NULL,
|
||||
g_thread_self_posix_impl,
|
||||
NULL,
|
||||
g_system_thread_equal,
|
||||
};
|
||||
|
||||
|
@ -316,8 +316,8 @@ struct _GThreadData
|
||||
gboolean joinable;
|
||||
};
|
||||
|
||||
static void
|
||||
g_thread_self_win32_impl (gpointer thread)
|
||||
void
|
||||
g_system_thread_self (gpointer thread)
|
||||
{
|
||||
GThreadData *self = TlsGetValue (g_thread_self_tls);
|
||||
|
||||
@ -406,8 +406,8 @@ g_thread_proxy (gpointer data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
g_thread_create_win32_impl (GThreadFunc func,
|
||||
void
|
||||
g_system_thread_create (GThreadFunc func,
|
||||
gpointer data,
|
||||
gulong stack_size,
|
||||
gboolean joinable,
|
||||
@ -449,8 +449,8 @@ g_thread_yield (void)
|
||||
Sleep(0);
|
||||
}
|
||||
|
||||
static void
|
||||
g_thread_join_win32_impl (gpointer thread)
|
||||
void
|
||||
g_system_thread_join (gpointer thread)
|
||||
{
|
||||
GThreadData *target = *(GThreadData **)thread;
|
||||
|
||||
@ -768,12 +768,12 @@ GThreadFunctions g_thread_functions_for_glib_use =
|
||||
g_private_new, /* private thread data */
|
||||
g_private_get,
|
||||
g_private_set,
|
||||
g_thread_create_win32_impl, /* thread */
|
||||
NULL, /* thread */
|
||||
g_thread_yield,
|
||||
g_thread_join_win32_impl,
|
||||
NULL,
|
||||
g_system_thread_exit,
|
||||
NULL,
|
||||
g_thread_self_win32_impl,
|
||||
NULL,
|
||||
g_system_thread_equal
|
||||
};
|
||||
|
||||
|
@ -708,7 +708,7 @@ g_thread_init_glib (void)
|
||||
g_threads_got_initialized = TRUE;
|
||||
g_private_init (&g_thread_specific_private, g_thread_cleanup);
|
||||
g_private_set (&g_thread_specific_private, main_thread);
|
||||
G_THREAD_UF (thread_self, (&main_thread->system_thread));
|
||||
g_system_thread_self (&main_thread->system_thread);
|
||||
|
||||
/* accomplish log system initialization to enable messaging */
|
||||
_g_messages_thread_init_nomessage ();
|
||||
@ -1188,7 +1188,7 @@ g_static_rec_mutex_lock (GStaticRecMutex* mutex)
|
||||
if (!g_thread_supported ())
|
||||
return;
|
||||
|
||||
G_THREAD_UF (thread_self, (&self));
|
||||
g_system_thread_self (&self);
|
||||
|
||||
if (g_system_thread_equal (&self, &mutex->owner))
|
||||
{
|
||||
@ -1221,7 +1221,7 @@ g_static_rec_mutex_trylock (GStaticRecMutex* mutex)
|
||||
if (!g_thread_supported ())
|
||||
return TRUE;
|
||||
|
||||
G_THREAD_UF (thread_self, (&self));
|
||||
g_system_thread_self (&self);
|
||||
|
||||
if (g_system_thread_equal (&self, &mutex->owner))
|
||||
{
|
||||
@ -1285,7 +1285,7 @@ g_static_rec_mutex_lock_full (GStaticRecMutex *mutex,
|
||||
if (depth == 0)
|
||||
return;
|
||||
|
||||
G_THREAD_UF (thread_self, (&self));
|
||||
g_system_thread_self (&self);
|
||||
|
||||
if (g_system_thread_equal (&self, &mutex->owner))
|
||||
{
|
||||
@ -1771,9 +1771,9 @@ g_thread_create_full (GThreadFunc func,
|
||||
result->thread.data = data;
|
||||
result->private_data = NULL;
|
||||
G_LOCK (g_thread);
|
||||
G_THREAD_UF (thread_create, (g_thread_create_proxy, result,
|
||||
g_system_thread_create (g_thread_create_proxy, result,
|
||||
stack_size, joinable, bound, 0,
|
||||
&result->system_thread, &local_error));
|
||||
&result->system_thread, &local_error);
|
||||
if (!local_error)
|
||||
{
|
||||
result->next = g_thread_all_threads;
|
||||
@ -1844,7 +1844,7 @@ g_thread_join (GThread* thread)
|
||||
g_return_val_if_fail (thread->joinable, NULL);
|
||||
g_return_val_if_fail (!g_system_thread_equal (&real->system_thread, &zero_thread), NULL);
|
||||
|
||||
G_THREAD_UF (thread_join, (&real->system_thread));
|
||||
g_system_thread_join (&real->system_thread);
|
||||
|
||||
retval = real->retval;
|
||||
|
||||
@ -1913,7 +1913,7 @@ g_thread_self (void)
|
||||
thread->thread.data = NULL;
|
||||
thread->private_data = NULL;
|
||||
|
||||
G_THREAD_UF (thread_self, (&thread->system_thread));
|
||||
g_system_thread_self (&thread->system_thread);
|
||||
|
||||
g_private_set (&g_thread_specific_private, thread);
|
||||
|
||||
|
@ -34,6 +34,16 @@ G_BEGIN_DECLS
|
||||
(memcpy (&(dest), &(src), GLIB_SIZEOF_SYSTEM_THREAD))
|
||||
#endif /* GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P */
|
||||
|
||||
G_GNUC_INTERNAL void g_system_thread_self (gpointer thread);
|
||||
G_GNUC_INTERNAL void g_system_thread_join (gpointer thread);
|
||||
G_GNUC_INTERNAL void g_system_thread_create (GThreadFunc func,
|
||||
gpointer data,
|
||||
gulong stack_size,
|
||||
gboolean joinable,
|
||||
gboolean bound,
|
||||
GThreadPriority priority,
|
||||
gpointer thread,
|
||||
GError **error);
|
||||
G_GNUC_INTERNAL gboolean g_system_thread_equal (gpointer thread1,
|
||||
gpointer thread2);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user