Re: main loop, threads and so on?



Now you have me. I know threads is the solution in this case as I have seen it said many times before. As yet I have never had to use them so I am afraid I cannot help with implementation details.


Not that complicated.

you'll need a call to `g_threads_init(NULL);'
in your main execution space before creating any threads.
(and you need your libraries to be compiled with
thread support, call g_thread_supported() to find out)

then you can call g_thread_create with some args (including a function pointer
of a specified type) to branch your thread (usualy posix threads).

to protect datum you have the GMutex api and g_condition_wait/g_condition_signal
will help you wake up and put to sleep your newly created thread.

you want to make sure that all functions that treat the GUI stay in one thread
(although there may be some shaky support for other methods) usualy your
main thread (parent).

you also have the power to kill your child thread at any given time from your
parent thread.

Cheers and happy doc reading ;-)
                                                       -Tristan






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