Commit Graph

11263 Commits

Author SHA1 Message Date
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
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
Colin Walters
1368533dc2 gvariant: Doc typo fix 2011-10-12 15:25:12 -04:00
Colin Walters
15b9f64004 gvariant: Briefly mention limits 2011-10-12 15:23:39 -04:00
Dan Winship
0af48a5d7b gthread-deprecated: add a mising "static" to a method 2011-10-12 13:59:33 -04:00
Dan Winship
95cab96515 giomodule: make the default_modules mutex recursive
It is possible for _g_io_module_get_default() to be called recursively
(eg, if a module of one type is loaded that tries to look up gsettings
from its init() method and ends up causing the gsettings module to be
loaded). So use a recursive mutex.
2011-10-12 13:57:44 -04:00
Dan Winship
71cf70b39c Simplify checks for CLOCK_MONOTONIC
Remove the complicated configure-time and runtime checks, and just use
CLOCK_MONOTONIC if it's defined.

https://bugzilla.gnome.org/show_bug.cgi?id=661421
2011-10-12 08:59:35 -04:00
Matthias Clasen
daede1dc27 Disable deprecations where appropriate in tests 2011-10-12 00:48:18 -04:00
Matthias Clasen
bcdb865c59 Disable deprecations where appropriate in tests 2011-10-12 00:37:02 -04:00
Matthias Clasen
7455dd370e Make single includes mandatory
This has been the official line since 2.17, which seems plenty
long enough for a transition phase.
2011-10-12 00:25:38 -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
Matthias Clasen
c6016458ba Update deprecation docs 2011-10-11 23:50:34 -04:00
Matthias Clasen
3d282dcc2e Silence deprecations in deprecated/ (again) 2011-10-11 23:44:43 -04:00
Chun-wei Fan
f5f242caf8 Update VS projects
Get rid of _CRT_SECURE_NO_WARNINGS and _CRT_NONSTDC_NO_WARNINGS
from the preprocessor definitions as those two macros are now defined
in msvc_recommended_pragmas.h, which is force-included in these projects
via the property sheets.  This will silence C4005 warnings on macro
redefinition.
2011-10-12 11:23:49 +08:00
Chun-wei Fan
b93d6ab83a Bug 661438: Update msvc_recommended_pragmas.h
Don't disable warning C4996 as that is the Visual C++ warning triggered by
__declspec(deprecated) and __declspec(deprecated('..."))-disabling that
warning will defeat the purpose of G_DPRECATED/G_DEPRECATED_FOR.

For people who don't want to see the GLib deprecation warnings during GLib
compilation, define GLIB_DISABLE_DEPRECATION_WARNINGS in the projects or
property sheet.
2011-10-12 10:53:30 +08:00
Chun-wei Fan
36ccdab760 Bug 661438: Fix up gmacros.h a bit
The macro here should be G_DEPRECATED, not G_GNUC_DEPRECATED.
2011-10-12 10:38:47 +08:00
Chun-wei Fan
17c713d3f6 Update VS property sheets
Missed the new glib/gstringchunk.h header that needed to be installed as
well.
2011-10-12 10:37:24 +08:00
Dan Winship
380ec80d07 g_time_val_from_iso8601: clarify the docs a bit 2011-10-11 19:28:59 -04:00