mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 06:33:41 +02:00
gthread: Rework to avoid holding a mutex half the time
This code was a persistent source of `-fsanitize=thread` errors when I was trying to use it on OSTree. The problem is that while I think this code is functionally correct, we hold a mutex during the writes, but not the reads, and TSAN (IMO correctly) flags that. Reading this, I don't see a reason we need a mutex at all. At the cost of some small code duplication between posix/win32, we can just pass the data we need down into each implementation. This ends up being notably cleaner I think than the awkward "lock/unlock to serialize" dance. (Minor review changes made by Philip Withnall <withnall@endlessm.com>.) https://gitlab.gnome.org/GNOME/glib/issues/1224
This commit is contained in:
committed by
Philip Withnall
parent
4631cd892d
commit
630fa82ed0
@@ -37,8 +37,11 @@ struct _GRealThread
|
||||
/* system thread implementation (gthread-posix.c, gthread-win32.c) */
|
||||
void g_system_thread_wait (GRealThread *thread);
|
||||
|
||||
GRealThread * g_system_thread_new (GThreadFunc func,
|
||||
GRealThread * g_system_thread_new (GThreadFunc proxy,
|
||||
gulong stack_size,
|
||||
const char *name,
|
||||
GThreadFunc func,
|
||||
gpointer data,
|
||||
GError **error);
|
||||
void g_system_thread_free (GRealThread *thread);
|
||||
|
||||
|
Reference in New Issue
Block a user