Exemple #1
0
void take() {
    while(flag) {
        unique_lock<mutex> locker(m_mutex);
        while(Q.empty())
            full.wait(locker);
        if(flag) {
            assert(!Q.empty());
            cout << "# " << Q.front() <<endl;
            Q.pop_front();
            empty.notify_all();
        }
    }
}
Exemple #2
0
boost::shared_ptr< const MapsBuffer::MapsRgb > 
MapsBuffer::getFront(bool print)
{
  boost::shared_ptr< const MapsBuffer::MapsRgb > depth_rgb;
  {
    boost::mutex::scoped_lock buff_lock (bmutex_);
    while (buffer_.empty ())
    {
      if (is_done)
        break;
      {
        boost::mutex::scoped_lock io_lock (io_mutex);
              //std::cout << "No data in buffer_ yet or buffer is empty." << std::endl;
      }
      buff_empty_.wait (buff_lock);
    }
    depth_rgb = buffer_.front ();
    buffer_.pop_front ();
  }
  
  if(print)
    PCL_INFO("%d maps left in the buffer...\n", buffer_.size ());
  
  return (depth_rgb);
}
 QList<QConsoleWidgetCommand> downOne(){
     if(commandBuffers.empty()){return QList<QConsoleWidgetCommand>();}
     --currentIndex;
     if( currentIndex<size() && currentIndex>=0){
         return commandBuffers[currentIndex  ];
     }else{
         currentIndex=0;
     }
     return commandBuffers[0];
 }
 QList<QConsoleWidgetCommand> upOne(){
     if(commandBuffers.empty()){return QList<QConsoleWidgetCommand>();}
     ++currentIndex;
     if( currentIndex< size() && currentIndex>=0){
         return commandBuffers[currentIndex  ];
     }else{
         currentIndex= size();
     }
     return *(commandBuffers.rbegin());
 }
Exemple #5
0
/*! @brief Returns true if the last press was a long one
     @param times a circular buffer of the click times
     @param durations a circular buffer of the click durations
     @param previoustime the previous time that this event has occured
 */
bool BehaviourProvider::longClick(const boost::circular_buffer<float>& times, const boost::circular_buffer<float>& durations, float& previoustime)
{
    if (times.empty())
        return false;
    else if (previoustime == times.back())
        return false;
    else if (durations.back() <= 800)
        return false;
    else
    {
        previoustime = m_current_time;
        return true;
    }
}
pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr 
PCDBuffer::getFront ()
{
	pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr cloud;
	{
		boost::mutex::scoped_lock buff_lock (bmutex_);
		while (buffer_.empty ())
		{
			if (is_done)
				break;
			{
				boost::mutex::scoped_lock io_lock (io_mutex);
				//std::cout << "No data in buffer_ yet or buffer is empty." << std::endl;
			}
			buff_empty_.wait (buff_lock);
		}
		cloud = buffer_.front ();
		buffer_.pop_front ();
	}
	return (cloud);
}