Re: Do I have to use thread safety if my GDK layer uses threads?



"Brian J. Murrell" <gtk-list-in interlinx bc ca> writes:

Hello,

I am writing a GTK+ 2.0 application using the DirectFB GDK layer.
DirectFB is multi-threaded (the GTK program itself runs in the initial
thread).  Does that mean that I need to write my GTK+ application in a
"thread safe" manner?

Shouldn't need to .... as long as you only access GTK+ and GDK functions
from one thread. (Assum DirectFB doesn't do anything unexpected.)
 
The reason I ask is that I came across a problem with my application.
At the start of my application I call:

  gtk_init (&argc, &argv);

and gtk_init() does a "bindtextdomain()" and my application is
getting suspended at gtk's call to "bindtextdomain()" with:

3346  rt_sigprocmask(SIG_SETMASK, NULL, [RTMIN], 8) = 0
3346  rt_sigsuspend([] <unfinished ...>

I am assuming that this is an issue with threading and non-safe use of
data and tried getting rid of the bindtextdomain() call in gtk's
gtk_init() function and everything seemed to work fine again.

I am at a loss to figure out what the unsafe data access is however
and how to guard it.

This doesn't look GTK+ related at all ... bindtextdomain() is 
part of the 'libintl' library or the C library. The version
in the GNU C library should definitely be thread safe, don't
know about other versions.

Regards,
                                        Owen



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