Re: Threads and waits
- From: Tristan Van Berkom <tvb gnome org>
- To: Fernando Apesteguía <fernando apesteguia gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Threads and waits
- Date: Wed, 15 Feb 2006 12:05:41 -0500
Fernando Apesteguía wrote:
Hi,
I have an app. that runs two threads, the main one and other thread that
collects information from files. I launch the thread by calling
pthread_create and here comes my first question
¿Should I use g_thread_create instead? Now I have no problems with these
pthreads and I can perform mutual exclusion with gdk_threads_enter() and
gdk_threads_leave() so I'm not sure about change the kind of thread.
Under some conditions I would like the collector thread to make a pause. I
don't know how to do it with POSIX functions. I've seen Glib's API
documentation and I'm not sure how could I make this. ¿Should I use a Gcond?
As I can see in documentation, g_thread_yield is not recommended to be used.
Yes, use a GCond.
g_thread is implemented as pthreads on linux... so as far as that
goes; you're safe for now.
I strongly recommend that you call only g_thread_* functions and not
pthread:
- This is what makes is portable after all
- gdk_threads_init() *must* be called for threads to work properly,
I believe gdk_threads_enter/leave is just a no-op otherwise.
- Mixing two api's to achieve the same goal is hazerdous; who ever
said that GDK garauntees to always use pthread on linux ???
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]