Ejemplo n.º 1
0
 //! Enqueues a log record
 void enqueue_unlocked(record_view const& rec)
 {
     const bool was_empty = m_queue.empty();
     m_queue.push(enqueued_record(rec));
     if (was_empty)
         m_cond.notify_one();
 }
Ejemplo n.º 2
0
	void put_( value_type const& va)
	{
		if ( ! active_() )
			throw task_rejected("queue is not active");
		queue_.push( va);
		fsem_.post();
	}
Ejemplo n.º 3
0
 /*!
  * \param cst	Pointer to the compressed suffix tree.
  * \param node  Root node of the traversal.
  * \param valid State of the iterator.
  * \param end   If valid=true and end=true, we get the end() iterator otherwise ``end'' has no effect.
  */
 cst_bfs_iterator(const Cst* cst, const value_type node, bool valid=true, bool end_it=false) {
     m_cst = cst;
     m_valid = valid;
     if (m_cst != nullptr and !end_it) {
         m_queue.push(node);
     }
 }
Ejemplo n.º 4
0
 void test_next_priority()
 {
     size_t next_prio = m_max_priority / 2;
     m_queue.push(next_prio, 10);
     ASSERT_EQ(next_prio, m_queue.priority_next());
     clear();
 }
Ejemplo n.º 5
0
		bool push(T instance, unsigned int timeout = 5) {
			boost::unique_lock<boost::shared_mutex> lock(mutex_, boost::get_system_time() + boost::posix_time::seconds(timeout));
			if (!lock) {
				return false;
			}
			queue_.push(instance);
			return true;
		}
 /// Place a packet into the outgoing queue
 bool send( packet_type const &outpkt )
 {
     bool r=false;
     if( outgoing_not_empty())
     {
         m_outgoing_queue.incoming() = outpkt;
         m_outgoing_queue.push();
         r=true;
     }
     return r;
 }
Ejemplo n.º 7
0
    bool enqueue(T const& data, bool notify = true) {
        if (!m_queue.push(data))
            return false;

        if (!notify) return true;

        boost::system::error_code ec;
        m_timer.cancel(ec);

        return true;
    }
Ejemplo n.º 8
0
    void test_mixed()
    {
        std::array<int, 10> priorities = {0,1,2,3,2,1,0,1,2,0};

        for (auto i : priorities)
            m_queue.push(i, i);

        for (auto it : m_queue) {
            ASSERT_LE(it, m_last_priority);
            m_last_priority = it;
        }
        clear();
        m_last_priority = m_max_priority;
    }
Ejemplo n.º 9
0
    //! 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();
    }
Ejemplo n.º 10
0
    void test_top()
    {
        std::array<int, 10> priorities = {0,1,2,3,2,1,0,1,2,0};

        for (auto i : priorities)
            m_queue.push(i, i);

        for (size_t i = 0; i < priorities.size(); ++i) {
            ASSERT_LE(m_queue.top(), m_last_priority);
            m_last_priority = m_queue.top();
            m_queue.pop();
        }
        clear();
        m_last_priority = m_max_priority;
    }
Ejemplo n.º 11
0
	//! 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;
	}
Ejemplo n.º 12
0
    //! 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;
    }
Ejemplo n.º 13
0
	virtual void push(const message_type &msg_arg)
	{
	   (void)my_queue.push(msg_arg);
	}
Ejemplo n.º 14
0
 void enqueue_( msg_type const& msg)
 { queue_.push( msg); }
Ejemplo n.º 15
0
 void fill(size_t num)
 {
     for (size_t i = 0; i < m_max_priority; ++i)
         for (size_t j = 0; j < num; ++j)
             m_queue.push(i, j);
 }
Ejemplo n.º 16
0
	void enqueue(queue_element_type* msg) {
		while (!m_messageQueue.push(msg))
			;
	}