Re: pthread_cond_signal in a callback function



> Is it possbile using pthread_cond_signal() on a callback fuction like
> below?

yes.

> void pthread_A (void *arg)
> {
>
> ............
>
> pthread_mutex_lock();
> while () pthread_cond_wait();
> pthread_mutex_unlock();


this code is wrong. if your actual code looks like this, it will never
do anything. i would hope that your code looks more like:

   pthread_mutex_lock();
   while (!some_condition_variable_set_in_your_code)
      pthread_cond_wait();
   pthread_mutex_unlock()

> In my program, the pthead_cond_signal () in the callback function,
> on_callback_of(), does not work with pthead_cond_wait() in the pthead
> function.

i have written many multithreaded apps with GTK+, gtkmm and pthreads
(linuxthreads) and i can assure you that they work together just fine.

--p



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