Commit Graph

172 Commits

Author SHA1 Message Date
Ryan Lortie
dc3727cc5f g_system_thread_join: rename to _wait() 2011-10-12 22:15:46 -04:00
Ryan Lortie
4bb968e335 g_system_thread_join: take GRealThread *
Make g_system_thread_join take the GRealThread* instead of a
GSystemThread.
2011-10-12 22:14:38 -04:00
Ryan Lortie
e064c9bfec thread: delegate allocation of GThread to backends
Add g_system_thread_new() and g_system_thread_free(), implemented with
GSlice.  Use those instead of g_new() and g_free().

Presently, the backends are both doing the same thing.  This will change
soon.
2011-10-12 22:04:39 -04:00
Ryan Lortie
d537726ded thread: stop sharing g_once_mutex
Unrelated code shouldn't be sharing the same mutex for no good reason --
particularly not across a file boundary.
2011-10-12 21:48:02 -04:00
Ryan Lortie
8cff9c57b1 thread: drop thread setup function hackery
Use a custom proxy function for the deprecated case instead.

Now GRealThread has strictly zero members dedicated to deprecated
functionality.
2011-10-12 21:48:02 -04:00
Ryan Lortie
a90a4b967f thread: reduce use of system_thread
The use of system_thread is now limited to joining.  We don't do that
for threads that we didn't create for ourselves, so we don't need to
call g_system_thread_self() to fill in system_thread for those.
2011-10-12 18:33:07 -04:00
Ryan Lortie
ed35d2719b thread: Remove the zero_thread
This was only used for redundant assertion checks.
2011-10-12 18:22:31 -04:00
Ryan Lortie
9ca4f14264 thread: call g_enumerable_thread_add via callback
There are no longer any functions defined in gthread-deprecated.c called
from gthread.c.
2011-10-12 17:05:50 -04:00
Ryan Lortie
f788a2e5e1 thread: use GPrivate for enumerable threads
Use a GPrivate to track the destruction of enumerable threads and remove
them from the list.
2011-10-12 17:05:50 -04:00
Ryan Lortie
9bb5a55bda GStaticPrivate: implement via GPrivate
Thanks to the modifications in 3d4846d923,
GStaticPrivate is not so directly tied in with GThread anymore.  It is
now a simple matter to cut it out completely by using a GPrivate to
store the GArray instead of storing it in the GThread.
2011-10-12 00:17:49 -04:00
Ryan Lortie
94b7d2ee6c Cleanup thread documentation 2011-10-06 12:01:53 -04:00
Matthias Clasen
3636cf2c64 Update threads docs for the demise of g_thread_init() 2011-10-05 22:43:22 -04:00
Ryan Lortie
69c0b4440e Deprecate g_{mutex,cond}_{new,free}()
Now that we have _init() and _clear(), these old calls are no longer
useful.

https://bugzilla.gnome.org/show_bug.cgi?id=660739
2011-10-04 20:08:14 -04:00
Ryan Lortie
47444dacc0 Deprecate g_thread_init()
Move the last few things that needed thread-safe initialisation to a
global ctor.

https://bugzilla.gnome.org/show_bug.cgi?id=660744
2011-10-04 15:31:49 -04:00
Ryan Lortie
794c1a30bc macro wrappers for g_once_init_enter/leave
Give the macro wrapper treatment to g_once_init_enter() and leave() in
the same style that we did for gatomic.

It is now possible to use these macros with any pointer-sized object,
and not just gsize.  The leave() macro ensures that the initialisation
result is a compatible type with the pointer that it is being written
to.

Just like with gatomic, there could be problems caused by use of (void*)
casts.  We'll see how that goes, and reevaluate if necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=660743
2011-10-04 11:00:31 -04:00
Matthias Clasen
9d989c7b8a Cosmetics 2011-10-02 23:53:56 -04:00
Matthias Clasen
fa6710ab6f Documentation fixes 2011-10-02 23:43:45 -04:00
Ryan Lortie
65056180dd locks: Add initialisation notes
For each of the 4, mention that static storage or _init() is needed.
2011-10-02 23:37:20 -04:00
Ryan Lortie
2a677d1370 locks: drop _INIT macros
All locks are now zero-initialised, so we can drop the G_*_INIT macros
for them.

Adjust various users around GLib accordingly and change the docs.

https://bugzilla.gnome.org/show_bug.cgi?id=659866
2011-10-02 22:33:10 -04:00
Matthias Clasen
3d4846d923 Deprecate GStaticPrivate and g_thread_foreach
This commit moves GStaticPrivate, g_thread_foreach and all
related functions and variables to gthread-deprecated.c. We
introduce some internal API to make this possible.

g_thread_foreach is not a very useful function, since there is
virtually nothing you can do with a GThread*, and implementing
it requires us to keep a list of threads around.

GStaticPrivate has been made redundant by adding comparable
capabilities to GPrivate.

https://bugzilla.gnome.org/show_bug.cgi?id=660635
2011-10-02 22:11:59 -04:00
Matthias Clasen
12287c8cc7 Don't put threads created with g_thread_new() on the list
This lets us avoid the overhead of maintaining the global
list in the non-deprecated case.

https://bugzilla.gnome.org/show_bug.cgi?id=660635
2011-10-02 22:11:58 -04:00
Matthias Clasen
1909d2398a Make thread names useful in a debugger
Associate the name with the system thread, so that debuggers
can see it. This is currently only implemented for Linux, using
prctl.

https://bugzilla.gnome.org/show_bug.cgi?id=660635
2011-10-02 22:11:58 -04:00
Matthias Clasen
0d1a92ca3d Add new thread creation API
Deprecate both g_thread_create functions and add
g_thread_new() and g_thread_new_full(). The new functions
expect a name for the thread.

Change GThreadPool, GMainContext and GDBus to create named threads.

https://bugzilla.gnome.org/show_bug.cgi?id=660635
2011-10-02 22:11:58 -04:00
Ryan Lortie
8e43470c38 Stop dithering over GPrivate
Take out the half-private g_private_init() stuff and replace it with a
G_PRIVATE_INIT macro that allows specifying a GDestroyNotify.

Expose the GPrivate structure in a public header.

Add a g_private_replace() to (sort of) match the functionality of
g_static_mutex_set().

Improve the documentation.

Deprecate g_private_new().
2011-10-02 20:04:03 -04:00
Matthias Clasen
7a75f56aa1 Add a few comments 2011-10-02 19:10:16 -04:00
Matthias Clasen
1a5cc98ca2 Rework the way GStaticPrivate data is freed
To avoid iterating threads in g_static_private_free(), defer freeing
the per-thread data to thread exit. The one complication here is
that it is possible for the static private index to be reused while
'old' data is still around. To deal with that case, store the 'owner'
with each per-thread data node, and free old data in
g_static_private_get() if the owner doesn't match. The remaining
possibility that a private index could be reused by a GStaticPrivate
with the same address is sufficiently unlikely that we can probably
ignore it.

With this change, per-thread data is now truly private again,
and we can drop the lock for it as well.

https://bugzilla.gnome.org/show_bug.cgi?id=660635
2011-10-02 18:32:41 -04:00
Matthias Clasen
6a31cc66cd Whitespace fixes 2011-10-02 17:11:42 -04:00
Matthias Clasen
3c02c64474 Clean up includes 2011-10-02 17:05:14 -04:00
Matthias Clasen
81e161edf2 GThread: cosmetic fix
Explicitly include gthread.h, don't rely on gthreadprivate.h
to pull it in.
2011-10-01 20:22:45 -04:00
Matthias Clasen
b4dc4902c6 Mark g_thread_create_with_stack_size as new API 2011-10-01 13:47:09 -04:00
Matthias Clasen
cde8cf16fa Some more gthread reshuffling 2011-09-29 20:23:19 -04:00
Dan Winship
f992c240e8 gthread: remove a stray reference to GStaticMutex 2011-09-29 09:59:15 -04:00
Matthias Clasen
81e395b00b More GThread docs tweaks 2011-09-25 01:32:41 -04:00
Matthias Clasen
900c467fd0 Move GThread docs around 2011-09-25 01:01:00 -04:00
Matthias Clasen
0ea89987e2 Move deprecated GThread functions to a separate file 2011-09-25 01:01:00 -04:00
Matthias Clasen
e34861da08 GThread: more doc updates 2011-09-25 01:01:00 -04:00
Matthias Clasen
4e44e23517 Drop G_THREADS_IMPL_NONE from the docs
GLib can no longer be built without thread support.
2011-09-25 01:00:59 -04:00
Chun-wei Fan
2b391940c0 gthread.c: Declare variable at start of block
This is so that C89 compilers will not complain.
2011-09-25 09:07:37 +08:00
Matthias Clasen
a485a0e565 Document G_THREADS_IMPL_WIN32 2011-09-24 19:04:46 -04:00
Matthias Clasen
d6b0af99d7 GThread doc additions 2011-09-24 19:01:02 -04:00
Matthias Clasen
558955dd85 Some gthread doc updates
Marking things as deprecated, mostly.
2011-09-22 01:16:41 -04:00
Ryan Lortie
42af8eb39d gthread: remove impl init functions 2011-09-21 16:06:56 -04:00
Ryan Lortie
894dd4f62b Revert "Drop an unused variable"
This reverts commit c7f9cd17d446938aaf4126e0753302676f66fd22.

The old macros in gthread.h used this variable, so it must remain in
place to keep ABI compatibility.
2011-09-21 16:06:56 -04:00
Matthias Clasen
8ef30eb3da Drop an unused variable 2011-09-21 16:06:56 -04:00
Ryan Lortie
ae2ac9e809 Move some things to deprecated/gthread.h 2011-09-21 16:06:56 -04:00
Ryan Lortie
14e6377a60 Deprecate g_thread_create_full()
Replace it with g_thread_create_with_stack_size() and a real function
implementation of g_thread_create().

Modify a testcase that was calling g_thread_create_full()
inappropriately (it was using the default values anyway).
2011-09-21 16:06:55 -04:00
Ryan Lortie
9621b1093e Drop g_thread_fail()
This is now unused.
2011-09-21 16:06:55 -04:00
Ryan Lortie
b2c1364ab2 g_system_thread_create: drop unused args
The 'bound' and 'priority' arguments are no longer in use, so drop them.
2011-09-21 16:06:55 -04:00
Ryan Lortie
2b4c303d61 Remove the concept of 'bound'
This was ignored on Windows.  On POSIX, where supported, it controlled
if we ended up with a proper system thread or a user-mode thread.  Linux
did not support this.
2011-09-21 16:06:55 -04:00
Ryan Lortie
cffed9a03a Remove g_thread_functions_for_glib_use_old
This has been unused for a while and it should definitely go away now
that g_thread_functions_for_glib_use is back in gthread.c.
2011-09-21 16:06:55 -04:00