本文整理汇总了C++中Strategy::onError方法的典型用法代码示例。如果您正苦于以下问题:C++ Strategy::onError方法的具体用法?C++ Strategy::onError怎么用?C++ Strategy::onError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Strategy
的用法示例。
在下文中一共展示了Strategy::onError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: block
void SocketMonitor::block( Strategy& strategy, bool poll, double timeout )
{
while ( m_dropped.size() )
{
strategy.onError( *this, m_dropped.front() );
m_dropped.pop();
if ( m_dropped.size() == 0 )
return ;
}
fd_set readSet;
FD_ZERO( &readSet );
buildSet( m_readSockets, readSet );
fd_set writeSet;
FD_ZERO( &writeSet );
buildSet( m_connectSockets, writeSet );
buildSet( m_writeSockets, writeSet );
fd_set exceptSet;
FD_ZERO( &exceptSet );
buildSet( m_connectSockets, exceptSet );
if ( sleepIfEmpty(poll) )
{
strategy.onTimeout( *this );
return;
}
int result = select( FD_SETSIZE, &readSet, &writeSet, &exceptSet, getTimeval(poll, timeout) );
if ( result == 0 )
{
strategy.onTimeout( *this );
return;
}
else if ( result > 0 )
{
processExceptSet( strategy, exceptSet );
processWriteSet( strategy, writeSet );
processReadSet( strategy, readSet );
}
else
{
strategy.onError( *this );
}
}
示例2: processExceptSet
void SocketMonitor::processExceptSet( Strategy& strategy, fd_set& exceptSet )
{
#ifdef _MSC_VER
for ( unsigned i = 0; i < exceptSet.fd_count; ++i )
{
int s = exceptSet.fd_array[ i ];
strategy.onError( *this, s );
}
#else
Sockets::iterator i;
Sockets sockets = m_connectSockets;
for ( i = sockets.begin(); i != sockets.end(); ++i )
{
int s = *i;
if ( !FD_ISSET( *i, &exceptSet ) )
continue;
strategy.onError( *this, s );
}
#endif
}