Re: gthread once
- From: Sebastian Wilhelmi <wilhelmi ira uka de>
- To: Miroslaw Dobrzanski-Neumann <mne mosaic-ag com>
- Cc: GTKDEV <gtk-devel-list gnome org>
- Subject: Re: gthread once
- Date: 19 Feb 2002 11:08:56 +0100
Hi Miroslaw,
> > * It is not guaranteed to work. (We have this discussion every
> > half year, and I think, I'm the top offender;-) Basically the
> > double check pattern is not safe for some (admittedly not so
> > common) systems. We could use this technique, where it is
> > allowed, and fall back to full locking on the other platforms.
> for such systems you can redefine the macro g_thread_once() to direct call to
> g_thread_once_real()
> it could be estimated by configure
Yeah, right, it's easy, I just noted, that it has to be done.
> > * I think, we should support calling a function, which takes an
> > argument (gpointer) and returns a gpointer to make this more
> > useful. Such an implementation could be used to implement
> > g_static_mutex_get_mutex_impl, which is my aim in including
> > g_once. Your implementation couldn't do that. Actually the
> > pthread implementation is of very limited use due to that. [I
> > didn't wrote that in the bug report, because i first thought
> > of it after submitting the report.]
> once function taking a parameter is no more invariant as it should be. Its
> outcome depends on the parameter passed. The initialization result can be
> stored in a global variable since it does not change after initialization has
> taken place.
>
> here a broken once issue (pseudocode)
> noone can tell how this code behave!!
The same is true, when you use 2 different functions with one GOnce var,
so where is the point? Of course this can be misused, but I can see
possible uses of this, e.g. you can annotate GOnce created data with the
specific function, which triggered the creation and so forth.
Bye,
Sebastian
--
Sebastian Wilhelmi
mailto:wilhelmi ira uka de
http://goethe.ira.uka.de/~wilhelmi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]