Re: Question around GOnce structure in Glib



Banginwar, Rajesh wrote:

> Hello,
>
>             We are currently in the process of standardizing GTK+
> libraries in LSB-Desktop project. During the process, I ran into the
> GOnce structure in Glib library. I will like to understand why the
> member variables of this structure are declared volatile. I am trying
> to find out if LSB should maintain these member volatile or if it is
> ok not to.
>
The struct members are marked volatile because they may be concurrently
accessed by other threads.  One of the g_once() implementations checks
one of the member variables outside of the protecting mutex (in a way
that is safe, given how this code works), so you don't want the compiler
to generate code that assumes the variable won't change underneath it.

That said, why would an LSB standard want to document something
different to the interface glib actually provides?

James.



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