Re: gthread once

Hi Miroslaw,

> To the bug 69688 I have attached (attachment id 6767) a patch with fast
> implementation of g_thread_once(). I is implementad in terms of already
> present gthread abstraction. I does not block the whole system while running
> the once handler but only all threads waiting on the particular once guard.
> the test case thread-test has been extended to run the once test also.
> Could you review the fix and apply if appropriate?

Firstly as a matter of fact this of course won't make it for 2.0.

Now to the implementation:

        * 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.
        * 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.]

Anyway, your code is a start. I'll have a look at improving it along the
lines outlined above.

Sebastian Wilhelmi
mailto:wilhelmi ira uka de

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