本文整理汇总了C++中Timeout::check方法的典型用法代码示例。如果您正苦于以下问题:C++ Timeout::check方法的具体用法?C++ Timeout::check怎么用?C++ Timeout::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timeout
的用法示例。
在下文中一共展示了Timeout::check方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: iocp_thread
void iocp_thread()
{
DWORD bytes_transferred;
OVER *over;
ULONG key;
while(true) {
bytes_transferred = 0;
BOOL completed = GetQueuedCompletionStatus(hIOCP,&bytes_transferred,&key,(OVERLAPPED**)&over,timeout);
if(key == KEY_STOP) {
if(log_level) std::cerr << "KEY_STOP" << std::endl;
break;
}
DWORD last_error = completed ? 0 : HandleLastError("GetQueuedCompletionStatus");
if(log_level) fprintf(stderr,"completed[%i] bytes_transferred[%i] over.operation[%i]\n",completed,bytes_transferred,over ? over->operation : 0);
if((!completed && last_error == WAIT_TIMEOUT)) {
fprintf(stderr,"WAIT_TIMEOUT\n");
}
if(timeout.check()) {
int i = CancelIo(hCom);
fprintf(stderr,"CancelIo = %i\n",i);
continue;
}
if(!completed || !over) {
continue;
}
if(over->operation == OP_READ) {
if(completed) {
long packet_found = data_received(read_buf,bytes_transferred);
if(!packet_found) {
Read(read_buf,1);
}
}
}
if(over->operation == OP_WRITE) {
if(data_sent(bytes_transferred,system::error_code(last_error,system::system_category())) == 0) {
Read(read_buf,1);
}
}
}
if(log_level) std::cerr << "iocp_thread stopped" << std::endl;
}