本文整理汇总了C++中Connection::LastUsed方法的典型用法代码示例。如果您正苦于以下问题:C++ Connection::LastUsed方法的具体用法?C++ Connection::LastUsed怎么用?C++ Connection::LastUsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::LastUsed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _Manager_Thread
int32 TCPManager::_Manager_Thread() {
// set_alarm(25000,B_PERIODIC_ALARM);
Connection *connection;
int32 connect_count;
int32 current_time;
// int32 last_used;
int32 time_out=DEFAULT_TIMEOUT;
while(!_quitter_) {
// if (acquire_sem(process_sem_1)==B_OK) {
// printf("processing\n");
connect_count=Connection::CountConnections();
if (connect_count>0) {
current_time=real_time_clock();
for (int32 i=0; i<connect_count; i++) {
if (lock.LockWithTimeout(25000)==B_OK)
{
// printf("TCP Manager: lock acquired\n");
connection=Connection::ConnectionAt(i);
if (!Connection::HasConnection(connection))
{
lock.Unlock();
snooze(10000);
continue;
}
if (connection->IsConnected())
{
if (connection->IsInUse())
{
if (!connection->NotifiedConnect())
{
if (!connection->already_connected)
connection->ConnectionEstablished();
connection->NotifyConnect();
} else
{
if (connection->IsDataWaiting())
{
connection->RetrieveData();
if (connection->owner!=NULL)
connection->owner->DataIsWaiting(connection);
}
}
} else
{
if (connection->IsDataWaiting())
{
// printf("TCP Manager: data is waiting on unused connection; receiving and flushing data\n");
int32 lastused=connection->LastUsed();
connection->RetrieveData();
connection->lastusedtime=lastused;
}
}
if ((connection->LastUsed()!=0) && ((current_time-connection->LastUsed())>=time_out))
{
// if (connection->owner!=NULL)
// connection->owner->DestroyingConnectionObject(connection);
connection->TimeOut();
Disconnect(connection);
}
} else
{
if (!connection->NotifiedDisconnect())
{
connection->NotifyDisconnect();
// Disconnect(connection);
}
else
{
if ((connection->LastUsed()!=0) && ((current_time-connection->LastUsed())>=time_out))
{
// if (connection->owner!=NULL)
// connection->owner->DestroyingConnectionObject(connection);
connection->TimeOut();
Disconnect(connection);
}
}
}
lock.Unlock();
}
snooze(10000);
}
}
snooze(25000);
// release_sem(process_sem_2);
// }
}
// set_alarm(B_INFINITE_TIMEOUT,B_PERIODIC_ALARM);
atomic_add(&Connection::SystemReady,-1);
return 0;
}