Re: Knowing if a GThread is still alive

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

 



On Sun, Sep 30, 2012 at 9:36 PM, Vivien Malerba <vmalerba@xxxxxxxxx> wrote:

So I'm looking for some advice on how to check if a GThread (say A) is still alive while my code executes in another thread (say B). I've thought about two ways to do this but could find none which seems to work:
...
 
2) configure thread A to execute a "cleanup" function when it exits (like atexit), but I don't think it's doeable

i think your second option is the better bet.   when each thread exits, use g_idle_add() to call a finalize/clean-up function, each thread calling the same function. 

since it's executed as part of the main loop, single concurrency is guaranteed.   pass an argument indicating which thread is exiting, and then do whatever housekeeping for each that is appropriate. 

as well, you can maintain a variable indicating if any given thread is active: set to true at thread start-up, and then false in the thread finalize callback.

richard
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux