Commit Graph

11281 Commits

Author SHA1 Message Date
Matthias Clasen
81431fa5b8 Add g_thread_try to the docs 2011-10-14 23:12:06 -04:00
Matthias Clasen
d000bf67f7 Update doc lists 2011-10-14 23:01:05 -04:00
Matthias Clasen
5ddcc284e8 Minor doc clarifications 2011-10-14 23:00:17 -04:00
Ryan Lortie
a6da2b9ff9 Mention thread API changes in README 2011-10-14 21:52:36 -04:00
Ryan Lortie
4359cbd810 I read the news today, oh boy... 2011-10-14 21:48:20 -04:00
Ryan Lortie
7ab25865f2 Stop checking for fork() across GMainContext
01ed78d525 introduced assertion checks for
creating a main context, forking, and attempting to use the main context
from the child side of the fork.

Some code (such as gnome-keyring-daemon) daemonise after calling
GMainContext.  That's probably still mostly safe since we still only
have one side of the fork touching the context afterwards.

This use case is still troubling, however, since if any worker threads
have been created at the time of the fork(), we could end up in the
classic situation of leaving some mutexes in a locked state when the
other threads disappear from the copy of the image that the child gets.

This will require some deeper thinking...
2011-10-14 20:01:22 -04:00
Ryan Lortie
51773c6c64 Mask all signals in GLib worker thread
Some code using GLib (gnome-keyring-daemon, for example) assumes that
they can catch signals by masking them out in the main thread and
calling sigwait() from a worker.

The problem is that our new worker thread catches the signals before
sigwait() has a chance and the default action occurs (typically
resulting in program termination).

If we mask all the signals in our worker, then this can't happen.
2011-10-14 20:01:22 -04:00
Florian Müllner
1ed88f0615 desktop-app-info: Add support for X-GNOME-Keywords
With search gaining traction as being the preferred way to locate
applications, the existing .desktop file fields meant for browsing
often produce insufficient results.
gnome-control-center introduced a custom X-GNOME-Keywords field for
that purpose, which we plan to support in gnome-shell as well.

https://bugzilla.gnome.org/show_bug.cgi?id=661763
2011-10-14 23:30:21 +02:00
Ryan Lortie
14e3b12823 g_cond_timed_wait: support NULL time parameter
It was undocumented, but this used to mean "wait forever".  Looks like
we have some uses of this internally and there may be others in the
wild...
2011-10-14 00:00:14 -04:00
Ryan Lortie
4033c616ff GCond: use monotonic time for timed waits
Switch GCond to using monotonic time for timed waits by introducing a
new API based on monotonic time in a gint64: g_cond_wait_until().

Deprecate the old API based on wallclock time in a GTimeVal.

Fix up the gtk-doc for GCond while we're at it: update the examples to
use static-allocated GCond and GMutex and clarify some things a bit.
Also explain the rationale behind using an absolute time instead of a
relative time.
2011-10-13 23:44:17 -04:00
Ryan Lortie
fd382156b8 tests: disable deprecation warnings for tests
We need to test deprecated functions, so don't warn us for doing so.
2011-10-13 10:51:35 -04:00
Ryan Lortie
3ebdb4d46a gutils: stop using GStaticPrivate
This was our last internal use.
2011-10-13 09:14:57 -04:00
Ryan Lortie
62fe053268 Revert "make struct _GThread private"
This reverts commit d904612100.

glibmm touches the contents of GThread, so this broke their build.
2011-10-13 09:00:54 -04:00
Ryan Lortie
d904612100 make struct _GThread private
Hide the definition of struct _GThread in gthreadprivate.h for now.

This is possibly an API break -- although the structure contents were
undocumented and it was not safe to access them in a meaningful way,
someone may have tried to do it anyway.  We'll leave it here for a while
to see if it causes any problems.

Avoid merging its contents with GRealThread for now, just incase we need
to expose it again.
2011-10-13 01:34:08 -04:00
Ryan Lortie
b1cc2579c1 tidy up gthreadprivate.h
Remove some unused includes, too.
2011-10-13 01:22:51 -04:00
Ryan Lortie
332f74a2fc drop g_thread_new_full()
We'll hold out on this until someone has a really convincing reason for
why they need to control the stack size.

If we do decide to add it back, it should probably have a name like
_new_with_stack_size(), not _full().
2011-10-13 01:17:36 -04:00
Ryan Lortie
430c5635f2 g_thread_new: never fail
Remove the GError argument from g_thread_new() and abort on failure.
Introduce g_thread_try() for those who want to handle failure.
2011-10-13 01:00:57 -04:00
Ryan Lortie
015f4b4513 thread: nuke the concept of 'joinable'
And remove the 'joinable' argument from g_thread_new() and
g_thread_new_full().

Change the wording in the docs.  Clarify expectations for
(deprecated) g_thread_create().
2011-10-13 00:43:33 -04:00
Ryan Lortie
b0e73ca390 GThread: make refcounting public 2011-10-13 00:29:04 -04:00
Ryan Lortie
62be9365d9 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.
2011-10-13 00:18:17 -04:00
Ryan Lortie
becb4b820f remove 'joinable' parameter to backends
Both backends are now oblivious to the concept of joinability, so don't
bother passing the parameter.
2011-10-13 00:01:28 -04:00
Ryan Lortie
dbf20d585f posix threads: joinable tweaks
Make the POSIX backend a little bit more like the win32 one in terms of
how we deal with joinability.

Calling g_system_thread_join() is now optional, and
g_system_thread_wait() can be safely called by multiple threads.

There is no longer any internal concept of joinability.
2011-10-12 23:40:02 -04:00
Ryan Lortie
f970dfc734 tests: don't #include <sys/resource.h> on win32 2011-10-12 23:25:12 -04:00
Ryan Lortie
45736d33bb win32 threads: simplify
Merge the GThreadData with the GThreadWin32 struct.  Drop the extra TLS
variable.

Close the handle on _free(), which means that there is no leak if
g_system_thread_join() isn't called.

Remove all internal concept of joinability.
2011-10-12 23:22:31 -04:00
Ryan Lortie
dfd466979b Only g_system_thread_free() our own threads
Keep track of if we created a thread for ourselves or if the GThread*
was allocated in response to g_thread_self() on a previously-unknown
thread.

Only call g_system_thread_free() in the first case.
2011-10-12 23:19:06 -04:00
Ryan Lortie
a5800ef336 Finish killing off GSystemThread 2011-10-12 23:04:15 -04:00
Ryan Lortie
e0c9757b9b win32 threads: use our own data, not system_thread
Stop using the generic system_thread field in GRealThread.  Use our own
pointer instead.
2011-10-12 22:53:52 -04:00
Ryan Lortie
67e28068e1 win32: fix function name clash 2011-10-12 22:49:39 -04:00
Ryan Lortie
2010f7f955 posix threads: use our own system_thread
Wrap GRealThread in a GThreadPosix that includes its own pthread_t field
called "system_thread" and use that instead of the generic field in
GRealThread.
2011-10-12 22:43:22 -04:00
Ryan Lortie
2f5486f020 thread creation: Simplify error handling
Instead of always returning non-NULL and finding out about errors via
the GError*, return NULL from the backend in the event of an error.
2011-10-12 22:43:22 -04:00
Ryan Lortie
e14a3746db Combine g_sytem_thread_{new,create}() 2011-10-12 22:43:22 -04:00
Ryan Lortie
a3f82c847f g_system_thread_create: drop 'data' arg
Since it's now always the same as the 'thread' arg.
2011-10-12 22:43:22 -04:00
Ryan Lortie
3237eaf5d5 g_system_thread_create: SystemThread -> RealThread
Just like g_system_thread_wait().
2011-10-12 22:43:22 -04:00
Matthias Clasen
6613b2f8fd Move more docs inline 2011-10-12 22:29:53 -04:00
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
Matthias Clasen
75ea14e885 Move GScanner docs inline 2011-10-12 21:49:44 -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
Matthias Clasen
2da83bbd36 Deprecate GCache
Ryan said it would be 'deprecated soon in GLib', when he removed
the use of this in GTK+. That was a year ago, so its about time
we act on it.
2011-10-12 19:55:02 -04:00
Ryan Lortie
39ae59c47e thread: Delete g_system_thread_self()
It's no longer used for anything at all.
2011-10-12 18:35:45 -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
b7f0506371 thread: hide g_static_rec_mutex_get_rec_mutex_impl
Unlike with GStaticMutex, this function was never part of the pre-2.32
ABI, so we should keep it tucked in.
2011-10-12 18:27:06 -04:00
Ryan Lortie
1f34ef4117 missed from last commit 2011-10-12 18:25:40 -04:00
Ryan Lortie
47e20ed3ac thread: remove GSystemThread assign/equal
These are no longer in use.
2011-10-12 18:24:48 -04:00
Ryan Lortie
903705edf2 thread: remove dead decl from gthreadprivate.h
This function hasn't existed for a while...
2011-10-12 18:23:20 -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
2b281e40f3 GStaticRecMutex: implement via GRecMutex
Instead of doing our own hacked-up version.

This also reduces use of GSystemThread.
2011-10-12 18:18:16 -04:00
Ryan Lortie
96904b6790 thread: use GSList for g_thread_foreach list
...instead of having a 'next' pointer in the GThread struct.

Now GThread contains no fields used only by deprecated code (except for
the rather generic setup function field).
2011-10-12 17:05:50 -04:00