本文整理汇总了C++中ConnectionPtr::removeListener方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionPtr::removeListener方法的具体用法?C++ ConnectionPtr::removeListener怎么用?C++ ConnectionPtr::removeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionPtr
的用法示例。
在下文中一共展示了ConnectionPtr::removeListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeConnection
bool ConnectionSet::removeConnection( ConnectionPtr connection )
{
{
lunchbox::ScopedWrite mutex( _impl->lock );
ConnectionsIter i = stde::find( _impl->allConnections, connection );
if( i == _impl->allConnections.end( ))
return false;
if( _impl->connection == connection )
_impl->connection = 0;
#ifdef _WIN32
ConnectionsIter j = stde::find( _impl->connections, connection );
if( j == _impl->connections.end( ))
{
Threads::iterator k = _impl->threads.begin();
for( ; k != _impl->threads.end(); ++k )
{
Thread* thread = *k;
if( thread->set.removeConnection( connection ))
{
if( !thread->set.isEmpty( ))
return true;
if( thread == _impl->thread )
_impl->thread = 0;
thread->event = EVENT_NONE;
thread->join();
delete thread;
break;
}
}
if ( k != _impl->threads.end() )
_impl->threads.erase( k );
}
else
{
connection->removeListener( _impl );
_impl->connections.erase( j );
}
#else
connection->removeListener( _impl );
#endif
_impl->allConnections.erase( i );
}
setDirty();
return true;
}
示例2: _addConnectionToThread
void ConnectionSet::_addConnectionToThread( ConnectionPtr connection )
{
_needRebalance = true;
lunchbox::ScopedWrite mutex( _impl->lock );
if ( _impl->threads.size() > 0 )
{
Thread* minThread = *( std::min_element(_impl->threads.begin(),
_impl->threads.end(),
ThreadConnectionsSizeComparator()) );
if ( minThread->set._impl->connections.size() < MAX_CONNECTIONS )
minThread->set.addConnection( connection );
else
{
Connections connections(1, connection);
_createThread( connections );
}
}
else
{
_isThreadMode = true;
size_t mid_connections = _impl->connections.size()/2;
Connections connections1(_impl->connections.begin(),
_impl->connections.begin() + mid_connections );
Connections connections2(_impl->connections.begin() + mid_connections,
_impl->connections.end() );
connections1.push_back( connection );
while( !_impl->connections.empty() )
{
ConnectionPtr lastConnection = _impl->connections.back();
lastConnection->removeListener( _impl );
_impl->connections.pop_back();
}
_createThread( connections1 );
_createThread( connections2 );
}
}