Re: Thread programming



On Monday 16 June 2003 17:32, Tristan Van Berkom wrote:

Hi,

This could work,

   - Create a GQueue and a GMutex to handle the queue.
   - in your main (GUI updating) thread, create a g_timeout_add
     function and every once and a while, come and check the queue like so
     ...
     g_mutex_lock(queue_mutex);
     /* process data in queue */
     g_mutex_unlock(queue_mutex);
     ....

     - in your child thread; when you have ready data; lock your mutex,
     add data to the queue and unlock mutex.

There's also GAsyncQueue, which does the same thing, but is slightly more 
convenient to use IMHO.

Cheers
-Tim




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