Hi,

I don't know why you should have RWLOCK mechanism on your problem, but it is 
not 'safe' to update widget in other thread except the main thread, 
g_idle_add() may suitable for you. This called in the main thread and you can 
safely update any widget in this function. Please note the GSourceFunc return 
value, when you returning TRUE (not 0) or FALSE (0), see the documentation.

gboolean update_widget (void *data)
{
  /* do widget updating based on variables */
  return FALSE;
}

void* thread_func (void *data)
{
  /* variable manipulation */
  g_idle_add ((GSourceFunc) update_widget, NULL);
}


--- donglongc...@163.com wrote:

From: donglongchao <donglongc...@163.com>
To: gtk-app <gtk-app-devel-list@gnome.org>
Subject: Do I need to use rwlock?
Date: Thu, 11 Jun 2009 10:55:14 +0800 (CST)

Hi,all

I have two threads.The first one is in charge of change data,and the second one 
is in charge of refresh the GUI based on the data changed by the first 
thread.For example,the second one will make a "entry" sensitive if a bool 
variable is changed to be "true" by the first thread.
And what I want to know is that do I need to use rwlock(or something like that) 
when I use the same variable in both the two threads?If yes,I want to know 
whether  there is a better method to solve this problem?Because I need to 
refresh many many widgets based on many many variables.
 Will someone help me?Thanks a lot.

Wish you happy.
Dong Longchao
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




_____________________________________________________________
Listen to KNAC, Hit the Home page and Tune In Live! ---> http://www.knac.com
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to