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


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

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


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

示例1: enqueue

    //! Enqueues log record to the queue
    void enqueue(record_view const& rec)
    {
        unique_lock< mutex_type > lock(m_mutex);
        std::size_t size = m_queue.size();
        for (; size >= MaxQueueSizeV; size = m_queue.size())
        {
            if (!overflow_strategy::on_overflow(rec, lock))
                return;
        }

        m_queue.push(rec);
        if (size == 0)
            m_cond.notify_one();
    }
开发者ID:Icenium,项目名称:BoostSharp,代码行数:15,代码来源:bounded_fifo_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: 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

示例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: test_pop

    void test_pop()
    {
        size_t num = 10, count = 0;

        fill(num);
        while (!m_queue.empty())
            m_queue.pop();

        ASSERT_EQ(0, m_queue.size());

        for (auto i : m_queue)
            count++;

        ASSERT_EQ(0, count);
        clear();
    }
开发者ID:hundeboll,项目名称:rlncd,代码行数:16,代码来源:test_queue.cpp

示例6: dequeue

    bool dequeue( msg_type & msg, boost::xtime const& xt)
    {
      typename boost::mutex::scoped_lock lock( mtx_);
      if ( active_ == false && empty_() ) return false;
      not_empty_cond_.timed_wait( 
				 lock,
				 xt,
				 boost::bind(
					     & Queue< T, Q >::consumers_activate_,
					     this) );
      if ( empty_() )
	msg.reset();
      else
	dequeue_( msg);
      if ( active_ == true && queue_.size() <= low_water_mark_)
	not_full_cond_.notify_one();
      return msg ? true : false;
    }
开发者ID:maoy,项目名称:mosaic,代码行数:18,代码来源:queue.hpp

示例7: try_timed_wait_for_data

    /// Returns immediately of queue size is >= immedeiate_size
    /// Otherwise, it will poll over 'ns' nanoseconds or on a signal
    /// until queue is not empty.
    inline bool try_timed_wait_for_data(size_t ns, size_t immediate_size) {
      m_mutex.lock();
      bool success = false;
      // Wait while the queue is empty and this queue is alive
      if (m_queue.size() < immediate_size) {
        if (m_queue.empty() && m_alive) {
          sleeping++;
          m_conditional.timedwait_ns(m_mutex, ns);
          sleeping--;
        }
      }
      // An element has been added or a signal was raised
      if(!m_queue.empty()) {
        success = true;
      }
      m_mutex.unlock();

      return success; 
    }
开发者ID:3upperm2n,项目名称:PowerGraph,代码行数:22,代码来源:blocking_queue.hpp

示例8: try_enqueue

    //! Attempts to enqueue log record to the queue
    bool try_enqueue(record_view const& rec)
    {
        unique_lock< mutex_type > lock(m_mutex, try_to_lock);
        if (lock.owns_lock())
        {
            const std::size_t size = m_queue.size();

            // Do not invoke the bounding strategy in case of overflow as it may block
            if (size < MaxQueueSizeV)
            {
                m_queue.push(rec);
                if (size == 0)
                    m_cond.notify_one();
                return true;
            }
        }

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

示例9: 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

示例10: size

	//! Returns the current number of nodes in the queue.
	size_type size() const { return m_queue.size(); }
开发者ID:olydis,项目名称:sdsl-lite,代码行数:2,代码来源:cst_iterators.hpp

示例11: full_

 bool full_() const
 {
   if ( high_water_mark_ == infinity_) return false;
   return queue_.size() > high_water_mark_;
 }
开发者ID:maoy,项目名称:mosaic,代码行数:5,代码来源:queue.hpp

示例12: size

 std::size_t size() const{
   return queue_.size();
 }
开发者ID:maoy,项目名称:mosaic,代码行数:3,代码来源:queue.hpp

示例13: size

 //! get the current size of the queue
 inline size_t size() {
   return m_queue.size();
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:4,代码来源:fiber_blocking_queue.hpp

示例14: size

		std::size_t size(unsigned int timeout = 5) {
			boost::shared_lock<boost::shared_mutex> lock(mutex_, boost::get_system_time() + boost::posix_time::seconds(timeout));
			if (!lock || queue_.empty())
				return 0;
			return queue_.size();
		}
开发者ID:mickem,项目名称:nscp,代码行数:6,代码来源:queue.hpp


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