Boost logo

Boost :

From: jsiek_at_[hidden]
Date: 2000-08-10 14:11:58


So one thing that bothers me about pthreads is the complexity of the
usage scenario for condition variables. Have any of you seen ways to
simplify this?

Just as a reminder, here's how the usage goes:

Thread 1:

  pthread_mutex_lock(&m);
  while (!some_condition)
    pthread_cond_wait(&cv, &m);
  // now some_condition == true
  // do something useful
  pthread_mutex_unlock(&m);

Thread 2:

  pthread_mutex_lock(&m);
  some_condition = true;
  pthread_mutex_unlock(&m);
  pthread_cond_signal(&cv);

Maybe there's a way to hide that while loop if a Predicate function
object is attached to the condition variable?

Cheers,

Jeremy


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk