GDK Threads...



Hello ,

I am trying to get the threads with gdk functional. I have the gtk-thread.c example.This example is 
a little basic, as neither thread is actually killed at anystage !

Firstly is there any documentation at all? I have only located the gdk reference guide with its
fleeting comments on the functions..

My assumption is that G_LOCK et al are built on the Posix threads, is this correct ? If so can I
use the pthreads commands directly, and bypass the gdk_threads_leave/g_thread_init stuff all
together ? What are these functions actually doing, as there seems no equivalence to them in 
the posix threads straight out of the box?

I have an application where two threads want to write to a window. I G_LOCK/G_UNLOCK the Pixmap
and drawing area, as each requests them. This seems to work okay.

The problem is when I pthread_cancel one thread. About one in 6 times, everything hangs. My 
assumption is that the thread has cancelled while stilling holding a mutex. I want to ensure that
the thread only exits in a certain place. There would appear to be no GDK functions for this, so I
am using the posix thread commands:

pthread_testcancel (added in one safe place in a thread loop)
pthread_setcanceltype( PTHREAD_CANCEL_DEFERRED , &type);
pthread_setcancelstate - set to PTHREAD_CANCEL_DISABLE while activating the mutexs.

My assumptions are that once given the pthread_cancel command the thread will ONLY stop at the 
pthread_testcancel place.

Even with the above, I still get hangs. Are these functions compatible with the implementation of
GDK threading ??

A little confused...

I look forward to your combined wisdom..

Best regards

/colin.







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