예제 #1
0
	bool take( value_type & va, chrono::system_clock::time_point const& abs_time)
	{
		mutex::scoped_lock lk( head_mtx_);
		bool empty = empty_();
		if ( ! active_() && empty)
			return false;
		if ( empty)
		{
		try
		{
				while ( active_() && empty_() )
                {
					if ( ! not_empty_cond_.timed_wait( lk, abs_time) )
                        return false;
                }
		}
		catch ( fiber_interrupted const&)
		{ return false; }
		}
		if ( ! active_() && empty_() )
			return false;
		swap( va, head_->va);
		pop_head_();
		return va;
	}
예제 #2
0
	void put_( value_type const& va)
	{
		if ( ! active_() )
			throw task_rejected("queue is not active");
		queue_.push( va);
		fsem_.post();
	}
예제 #3
0
	bool take( value_type & va)
	{
		mutex::scoped_lock lk( head_mtx_);
		bool empty = empty_();
		if ( ! active_() && empty)
			return false;
		if ( empty)
		{
		try
		{
				while ( active_() && empty_() )
					not_empty_cond_.wait( lk);
		}
		catch ( fiber_interrupted const&)
		{ return false; }
		}
		if ( ! active_() && empty_() )
			return false;
		swap( va, head_->va);
		pop_head_();
		return va;
	}
예제 #4
0
	void put( T const& t)
	{
		typename node_type::ptr new_node( new node_type() );
		{
			mutex::scoped_lock lk( tail_mtx_);

			if ( ! active_() )
				throw std::runtime_error("queue is not active");

			tail_->va = t;
			tail_->next = new_node;
			tail_ = new_node;
		}
		not_empty_cond_.notify_one();
	}
예제 #5
0
	bool active() const
	{ return active_(); }