FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
template<typename Data>
bool FB::SafeQueue< Data >::timed_wait_and_pop ( Data &  popped_value,
const boost::posix_time::time_duration &  duration 

Tries to pop a value off the front of the queue; if the queue is empty it will wait for the specified duration until something is pushed onto the back of the queue by another thread or until the duration times out.

[out]popped_valueThe popped value.
durationThe duration of time for which to wait
true if a value is returned, false if the queue was empty

Definition at line 100 of file SafeQueue.h.

101  {
102  boost::mutex::scoped_lock lock(the_mutex);
103  if(the_queue.empty())
104  {
105  // Wait for the specified duration if no values are there
106  the_condition_variable.timed_wait(lock, duration);
107  }
109  // See if a value was added; if not, we just timed out
110  if(the_queue.empty())
111  {
112  return false;
113  }
115  popped_value=the_queue.front();
116  the_queue.pop();
117  return true;
118  }