Re: When to call g_thread_init(), again...

I forgot g_thread_init takes args, so nvm the constructor version.

2008/8/15 Havoc Pennington <hp pobox com>
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.

gtk-devel-list mailing list
gtk-devel-list gnome org

Please note that according to the German law on data retention,
information on every electronic information exchange with me is
retained for a period of six months.
[Bitte beachten Sie, dass dem Gesetz zur Vorratsdatenspeicherung zufolge
jeder elektronische Kontakt mit mir sechs Monate lang gespeichert wird.]

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]