本文整理汇总了C++中WallClockTimer::restart方法的典型用法代码示例。如果您正苦于以下问题:C++ WallClockTimer::restart方法的具体用法?C++ WallClockTimer::restart怎么用?C++ WallClockTimer::restart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WallClockTimer
的用法示例。
在下文中一共展示了WallClockTimer::restart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillCache
void CurlStreamFile::fillCache(std::streampos size){
#if 1
assert(size >= 0);
if(! _running || _cached >=size){
return ;
}
fd_set readfd, writefd, exceptfd;
int maxfd;
CURLMcode mcode;
timeval tv;
//hard-coded slect timeout
//this number is kept low to give more thread switch
//opportunities while waitting for a load
const long maxSleepUsec = 10000; //1/100 of a second
const unsigned int userTimeout = 60000;
WallClockTimer lastProgress;
while(_running){
fillCacheNonBlocking();
if(_cached>=size || !_running) break;
FD_ZERO(&readfd);
FD_ZERO(&writefd);
FD_ZERO(&exceptfd);
mcode = curl_multi_fdset(_mCurlHandle, &readfd, &writefd,
&exceptfd, &maxfd);
if(mcode != CURLM_OK){
throw SnailException(curl_multi_strerror(mcode));
}
if(maxfd<0){
//as of libcurl 7.21.x, the DNS resolving appears to be
//going on in the background, so curl_multi_fdset fails to
//return anything useful, So we use the user timeout value
//to give DNS enough time to resolve the lookup
if(userTimeout && lastProgress.elapsed()>userTimeout){
return ;
}else{
continue;
}
}//if(maxfd<0)
tv.tv_sec = 0;
tv.tv_usec = maxSleepUsec;
//wait for data on the filedescriptors until a timeout set in rc file
int ret = select(maxfd+1, &readfd, &writefd, &exceptfd, &tv);
#if !defined(WIN32)
if(ret == -1){
if(errno == EINTR){
cout<<"select() was interrupted by a singal"<<endl;
ret = 0;
}else{
std::ostringstream os;
os<<"error polling data from connection to"<<_url<<":"<<strerror(errno);
throw SnailException(os.str());
}
}
#endif
if(!ret){
//timeout check the clock to see
//if we expired the user timeout
if(userTimeout && lastProgress.elapsed() > userTimeout){
cout<<"timeout ("<<userTimeout<<") while loading from URL"<<_url<<endl;
return ;
}
}else{
lastProgress.restart();
}
}//while(....
processMessages();
#endif
}