Re: Does gtk have issues with STL?

a nice discussion (with examples) of all this here:

and, g_idle_add() is indeed thread safe.  it was written that way, on purpose.  there's really no mystery to a function being thread-safe or not, either it was written intended to be, or it wasn't.  gtk generally wasn't, so it isn't.

not sure why you think that it is accessing data shared by threads.  it does exactly one thing, take the arguments provided by the caller, and place a call to the specified function on the main loop queue.  i don't see where it needs to access any common memory.  (could easily have a look at the function itself, i suppose.)

and, whether you gain an improvement in performance by removing your mutex calls, that depends on how much multiple calls to g_idle_add() is actually colliding.  if they never collide, you won't notice any improvement.  if you call g_idle_add() 100X/second, you will definitely see an improvement.  best way to answer this is run your own benchmarks and assess yourself, there's really no other way to tell.



On Feb 12, 2008 10:19 PM, Vallone, Anthony <anthony vallone lmco com> wrote:

> You do not need to call gdk_thread_init()
> if you are only invoking GDK/GTK+ functions by message passing via
> g_idle_add() (that is, if you are not calling

That's interesting.  g_idle_add() is thread safe without telling it to
use mutex locking? Based on the docs, I've always called g_thread_init
assuming I had to.  This may have a complicated answer, but how does it
safely manage being called by multiple threads given that it is probably
accessing data shared by the threads?

Also, will I get any performance improvement if I remove it?
gtk-list mailing list
gtk-list gnome org

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