Esempio n. 1
0
// 添加到等待发送队列中,是否为延后由线程对象来发送,主要触
bool CQueueMgr::Add( const char *id, unsigned int seq, void *data , bool send )
{
	_mutex.lock() ;

	CQueue *p = NULL ;
	CMapQueue::iterator it = _index.find( id ) ;
	if ( it == _index.end() ) {
		p = new CQueue(_pCaller, _maxent ) ;
		p->_id = id ;
		_queue.push( p ) ;
		_index.insert( std::make_pair(id, p ) ) ;
	} else {
		p = it->second ;
	}
	bool success = p->Add( seq, data, _maxspan , send ) ;

	_mutex.unlock() ;

	_monitor.notify() ;

	return success ;
}