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


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

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


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

示例1: enqueue

 //! Add an element to the blocking queue
 inline void enqueue(const T& elem, bool wake_consumer = true) {
   m_mutex.lock();
   m_queue.push_back(elem);
   // Signal threads waiting on the queue
   if (wake_consumer && sleeping) wake_a_fiber();
   m_mutex.unlock();
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:8,代码来源:fiber_blocking_queue.hpp

示例2: enqueue_conditional_signal

 inline void enqueue_conditional_signal(const T& elem, size_t signal_at_size) {
   m_mutex.lock();
   m_queue.push_back(elem);
   // Signal threads waiting on the queue
   if (sleeping && m_queue.size() >= signal_at_size) m_conditional.signal();
   m_mutex.unlock();
 }
开发者ID:3upperm2n,项目名称:PowerGraph,代码行数:7,代码来源:blocking_queue.hpp

示例3: enqueue

 //! Add an element to the blocking queue
 inline void enqueue(const T& elem) {
   m_mutex.lock();
   m_queue.push_back(elem);
   // Signal threads waiting on the queue
   if (sleeping) m_conditional.signal();
   m_mutex.unlock();
 }
开发者ID:3upperm2n,项目名称:PowerGraph,代码行数:8,代码来源:blocking_queue.hpp

示例4: schedule

 static inline void
 schedule (const caction& ad)
 {
   context_map_type::iterator pos = context_map_.find (ad.automaton);
   kassert (pos != context_map_.end ());
   
   automaton_context* c = pos->second;
   !c->push_back (ad);
   
   ready_queue_.push_back (c);
 }
开发者ID:jrwilson,项目名称:Lily,代码行数:11,代码来源:global_fifo_scheduler.hpp

示例5: finish


//.........这里部分代码省略.........
	  // 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 ();
	  }
	  break;
	case INTERNAL:
	case SYSTEM:
	  // +EEE
	  action_.automaton->lock_execution ();
	  break;
	}
	
	if (!c->empty ()) {
	  // Automaton has more actions, return to ready queue.
	  ready_queue_.push_back (c);
	}

	action_.automaton->execute (*action_.action, action_.parameter, output_buffer_a_, output_buffer_b_);
      }

      // Out of actions.
      action_.automaton = shared_ptr<automaton> ();
      irq_handler::wait_for_interrupt ();
    }
  }
开发者ID:jrwilson,项目名称:Lily,代码行数:101,代码来源:global_fifo_scheduler.hpp


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