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

Threads problem



Hi,

I've got a problem using threads in my program. I use Gib 1.2 threads and
pthread

I've created a tread which does:

while(1)
{
	g_mutex_lock(display->draw_lock);
	while (!display->start_draw)
		g_cond_wait(display->draw_cond,display->draw_lock);
	g_mutex_unlock(display->draw_lock);
		
	if (GTK_OBJECT_DESTROYED(GTK_OBJECT(display)))
	{
		break;
	}
	....
}

pthread_exit(NULL);

display is a custom GtkWidget.

In the destroy function of that widget i do among other things:

{
	display->start_draw = TRUE;
	g_cond_broadcast(display->draw_cond);
	g_assert(pthread_join(display->draw_thread,&result) == 0);
	...
}

So i figure this should shutdown the first thread:
1) set start_draw to TRUE
2) Signal the GCond
3) This checks the while  which is false and exists the loop (and unlocks
the mutex)
4) GTK_OBJECT_DESTROYED(`GTK_OBJECT(display)) is true (called from the
destroy function)
5) It breaks the main while(1)
6) It runs pthread_exit(), the thread is closed and the pthread_join in the
main loop continues

However this doesn't happen. The GCond just remains locked...

What am i doing wrong here?????


Also , display (typ: AzmivDisplay) is a child of a GtkEventBox, containing
a GtkDrawingArea. On both the expose events are enabled
(gtk_widget_set_events) , but i don't recieve any: no expose , no
configure, nothing. The size of the widget remains 1x1 , while i do a
gtk_drawing_area_size(), with values > 1 (128 x 128). Again, why doesn't
anything happen?????

Jeroen




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