当前位置: 首页>>代码示例>>C++>>正文


C++ queue_type::front方法代码示例

本文整理汇总了C++中queue_type::front方法的典型用法代码示例。如果您正苦于以下问题:C++ queue_type::front方法的具体用法?C++ queue_type::front怎么用?C++ queue_type::front使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在queue_type的用法示例。


在下文中一共展示了queue_type::front方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pop

		boost::optional<T> pop(unsigned int timeout = 5) {
			boost::unique_lock<boost::shared_mutex> lock(mutex_, boost::get_system_time() + boost::posix_time::seconds(timeout));
			if (!lock || queue_.empty())
				return boost::optional<T>();
			boost::optional<T> ret = queue_.front();
			queue_.pop();
			return ret;
		}
开发者ID:mickem,项目名称:nscp,代码行数:8,代码来源:queue.hpp

示例2: return

 //! Equality operator.
 bool operator==(const iterator& it)const {
     if (m_queue.size() != it.m_queue.size()) {   // if the queue size is different
         return false;                            // the state of the to iterator are different
     }
     if (m_queue.empty()) {  // if the queue is empty, we have to check if they are valid and
         return it.m_valid == m_valid and it.m_cst == m_cst; // belong to the same cst
     }
     return (it.m_valid == m_valid) // valid status is equal => for end() iterator
            and (it.m_cst == m_cst) // iterator belongs to the same cst
            and (it.m_queue.front() == m_queue.front())  // front element and
            and (it.m_queue.back() == m_queue.back());  //  back element are the same.
 }
开发者ID:Alienfeel,项目名称:sdsl-lite,代码行数:13,代码来源:cst_iterators.hpp

示例3: make_pair

 inline std::pair<T, bool> try_dequeue_in_critical_section() {
   T elem = T();
   // Wait while the queue is empty and this queue is alive
   if (m_queue.empty() || m_alive == false) {
     return std::make_pair(elem, false);
   }
   else {
     elem = m_queue.front();
     m_queue.pop_front();
     if (m_queue.empty() && sleeping_on_empty) {
       m_empty_conditional.signal();
     }
     return std::make_pair(elem, true);
   }
 }
开发者ID:3upperm2n,项目名称:PowerGraph,代码行数:15,代码来源:blocking_queue.hpp

示例4: try_dequeue

    //! Attempts to dequeue log record from the queue, does not block if the queue is empty
    bool try_dequeue(record_view& rec)
    {
        lock_guard< mutex_type > lock(m_mutex);
        const std::size_t size = m_queue.size();
        if (size > 0)
        {
            rec.swap(m_queue.front());
            m_queue.pop();
            if (size == MaxQueueSizeV)
                overflow_strategy::on_queue_space_available();
            return true;
        }

        return false;
    }
开发者ID:Icenium,项目名称:BoostSharp,代码行数:16,代码来源:bounded_fifo_queue.hpp

示例5:

	//! Prefix increment of the iterator.
	iterator& operator++()
	{
		if (!m_valid) return *this;
		if (m_queue.empty()) {
			m_valid = false;
			return *this;
		}
		value_type v = m_queue.front();
		m_queue.pop();
		value_type child = m_cst->select_child(v, 1);
		while (m_cst->root() != child) {
			m_queue.push(child);
			child = m_cst->sibling(child);
		}
		return *this;
	}
开发者ID:olydis,项目名称:sdsl-lite,代码行数:17,代码来源:cst_iterators.hpp

示例6: make_pair

    /**
    * Returns an element if the queue has an entry.
    * returns [item, false] otherwise.
    */
    inline std::pair<T, bool> try_dequeue() {
      if (m_queue.empty() || m_alive == false) return std::make_pair(T(), false);
      m_mutex.lock();
      T elem = T();
      // Wait while the queue is empty and this queue is alive
      if (m_queue.empty() || m_alive == false) {
        m_mutex.unlock();
        return std::make_pair(elem, false);
      }
      else {
        elem = m_queue.front();
        m_queue.pop_front();
      }
      m_mutex.unlock();

      return std::make_pair(elem, true);
    }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:21,代码来源:fiber_blocking_queue.hpp

示例7: dequeue_ready

    //! Dequeues log record from the queue, blocks if the queue is empty
    bool dequeue_ready(record_view& rec)
    {
        unique_lock< mutex_type > lock(m_mutex);

        while (!m_interruption_requested)
        {
            const std::size_t size = m_queue.size();
            if (size > 0)
            {
                rec.swap(m_queue.front());
                m_queue.pop();
                if (size == MaxQueueSizeV)
                    overflow_strategy::on_queue_space_available();
                return true;
            }
            else
            {
                m_cond.wait(lock);
            }
        }
        m_interruption_requested = false;

        return false;
    }
开发者ID:Icenium,项目名称:BoostSharp,代码行数:25,代码来源:bounded_fifo_queue.hpp

示例8: dequeue_

 void dequeue_( msg_type & msg)
 {
   msg = queue_.front();
   queue_.pop();
 }
开发者ID:maoy,项目名称:mosaic,代码行数:5,代码来源:queue.hpp

示例9: finish

  static inline void
  finish (bool output_fired,
	  bd_t bda,
	  bd_t bdb)
  {
    if (action_.automaton.get () != 0) {
      // We were executing an action of this automaton.

      switch (action_.action->type) {
      case INPUT:
	// We were executing an input.  Move to the next input.
	++input_action_pos_;
	proceed_to_input ();
	// -EEE
	input_action_list_.front ()->output_action.automaton->unlock_execution ();
	finish_output ();
	break;
      case OUTPUT:
	// We were executing an output ...
	if (output_fired) {
	  // ... and the output output did something.
	  output_buffer_a_ = action_.automaton->lookup_buffer (bda);
	  // Synchronize the buffers.
	  if (output_buffer_a_.get () != 0) {
	    output_buffer_a_->sync (0, output_buffer_a_->size ());
	  }
	  output_buffer_b_ = action_.automaton->lookup_buffer (bdb);
	  if (output_buffer_b_.get () != 0) {
	    output_buffer_b_->sync (0, output_buffer_b_->size ());
	  }
	  // Proceed to execute the inputs.
	  input_action_pos_ = input_action_list_.begin ();
	  // This does not return if there are inputs.
	  proceed_to_input ();
	}
	// No input actions to execute.
	// -EEE
	action_.automaton->unlock_execution ();
	finish_output ();
	break;
      case INTERNAL:
      case SYSTEM:
	// -EEE
	action_.automaton->unlock_execution ();
	break;
      }
    }

    // We are done with the current action.
    action_.automaton = shared_ptr<automaton> ();

    for (;;) {

      irq_handler::process_interrupts ();

      while (!ready_queue_.empty ()) {
	// Get the automaton context and remove it from the ready queue.
	automaton_context* c = ready_queue_.front ();
	ready_queue_.pop_front ();

	// Load the action.
	action_ = c->front ();
	c->pop_front ();

	// The automaton exists.  Continue loading and execute.
	switch (action_.action->type) {
	case INPUT:
	  // Error.  Not a local action.
	  kpanic ("Non-local action on execution queue");
	  break;
	case OUTPUT:
	  {
	    kassert (input_action_list_.empty ());
	    // Copy the bindings.
	    action_.automaton->copy_bound_inputs (action_, back_inserter (input_action_list_));
	    
	    // Sort the bindings by input automaton.
	    sort (input_action_list_.begin (), input_action_list_.end (), sort_bindings_by_input ());
	    
	    // We lock the automata in order.  This is called Havender's Principle.
	    bool output_locked = false;
	    for (input_action_list_type::const_iterator pos = input_action_list_.begin ();
		 pos != input_action_list_.end ();
		 ++pos) {
	      shared_ptr<automaton> input_automaton = (*pos)->input_action.automaton;
	      if (!output_locked && action_.automaton->aid () < input_automaton->aid ()) {
		// +EEE
		action_.automaton->lock_execution ();
		output_locked = true;
	      }
	      // +FFF
	      input_automaton->lock_execution ();
	    }
	    if (!output_locked) {
	      // +EEE
	      action_.automaton->lock_execution ();
	      output_locked = true;
	    }
	    
	    input_action_pos_ = input_action_list_.begin ();
//.........这里部分代码省略.........
开发者ID:jrwilson,项目名称:Lily,代码行数:101,代码来源:global_fifo_scheduler.hpp


注:本文中的queue_type::front方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。