Re: When to call g_thread_init(), again...
- From: "Havoc Pennington" <hp pobox com>
- To: "Tor Lillqvist" <tml iki fi>
- Cc: GTK Devel List <gtk-devel-list gnome org>
- Subject: Re: When to call g_thread_init(), again...
- Date: Fri, 15 Aug 2008 17:05:35 -0400
I'd argue mandatory init functions are more or less always wrong, they
all train-wreck in a similar way ... unfortunately every "G"-inspired
library seems to gratuitously have them.
If the init function has no args, then it should be possible for the
library to just deal with it and call it automatically. Most libraries
have some sensible places to insert init calls or init specific
subsystems on demand. In particular methods on objects never need to
check for init, since you have to create an instance first, only
constructors need to check for init.
If the init function does have arguments, then you end up with a
requirement that all libraries and modules calling it must call it
with the same args ... which isn't possible ... so init functions with
arguments are broken unless the *app* and never a library will always
call the init function.
All the gthread functions seem to check g_thread_supported() anyway
which is just the variable g_threads_got_initialized, so they could as
easily do "if (!g_threads_got_initialized) { g_thread_init(NULL); }"
g_thread_init() only makes sense when the arg is non-NULL and the
*app* calls it in main(). My opinion anyway.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]