gthreads vs pthread




Hello, i m using threads in a glib-only project, a service daemon, i have implemented them using GThreads, 
but i see now that GThreads is only a wrapper around pthreads (with the corresponding overhead from doing so) 
and does not provide any additional benefit (if i dont mistake the only real benefit is the cross platform 
feature). 
My application uses threads heavily, so i m not sure if i should go with pthreads or Gthread, just to 
clarify, i m hesitating because of the overhead of wrapping pthreads and also a more generic code, i m also 
100% sure that the daemon will always run on linux or unix with a pthread implementation, regarding this, i 
have a few questions, i m just recently using Glib so i have no experience in other projects with glib, so i 
would like to know:

1. if i dont issue the g_thread_init, at the beginning of my application, will there be any problem in glib 
itself? some functions or functionality willl cease to work or work incorrectly ?
2. Can i just use Glib with pthread instead of GThread ? i know that the main loop and GAsyncQueue will work 
out of the box.
3. The documentation says that by issuing g_thread_init Glib will become thread safe, i dont understand this, 
if i dont issue the command Glib will not work in a multithreated environment ?
4. If in the future i use glib in another project and decided to use pthread in my code but i know GTK uses 
GThread inside, will this be a problem? will it be overhead because i would be using pthreads and GThread 
together ? 
5. What would you use? why?


thanks!
                                          


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