thread: simplify 'free' process

GThread is freed using some very slightly confusing logic: if the thread
was created 'joinable', then the structure is freed after the join()
call succeeds (since we know the thread has exited).  If the thread was
not created 'joinable' then the free is when the thread quits (since we
know 'join' will not be called later).

Move to a straight ref-counting system: 1 ref owned by the thread and 1
extra ref if the thread is joinable.  Both thread quit and joining will
decrease the refcount by 1.
This commit is contained in:
Ryan Lortie
2011-10-13 00:18:17 -04:00
parent becb4b820f
commit 62be9365d9
2 changed files with 20 additions and 23 deletions

View File

@@ -59,6 +59,7 @@ struct _GRealThread
{
GThread thread;
gint ref_count;
gboolean ours;
const gchar *name;
gpointer retval;