소스 검색

代码优化

Jason 2 주 전
부모
커밋
7aff8a7c48
1개의 변경된 파일11개의 추가작업 그리고 10개의 파일을 삭제
  1. 11 10
      gamelog/HttpSocket.cpp

+ 11 - 10
gamelog/HttpSocket.cpp

@@ -222,14 +222,15 @@ static map<string, stUserInfo> map_acctouserinfo;
 static bool bAllPageDone = false;   //这次请求是否请求完所有分页
 void HttpSocket::init()
 {
-	static __int64	itimefrom = 0;
-	static __int64	itimeto = 0;
-	static __int32 ipage = 0;
-
+	__int64	itimefrom = 0;
+	__int64	itimeto = 0;
+	__int32 ipage = 0;
+	__int64 inowtime = 0;
+	bool	bFirst = true;
 	loaddbsynctime(itimefrom, itimeto, ipage, bAllPageDone);
 	while (true)
 	{
-		static __int64 inowtime = funclib::gettimestamp();
+		inowtime = funclib::gettimestamp();
 		if (itimeto == 0)
 		{
 			itimeto = inowtime - 1000;
@@ -237,19 +238,19 @@ void HttpSocket::init()
 		}
 		else if (inowtime - itimeto < 1000)
 		{
-			if(!bAllPageDone)
-				continue;
 			this_thread::sleep_for(milliseconds(itimeto + 1000 - inowtime));
 		}		
 
-		if (bAllPageDone)
+		if (!bFirst && !bAllPageDone)
+			continue;
+		else
 			ipage = 0;
 		bAllPageDone = false;
+		bFirst = false;
 
 		itimefrom = itimeto;
 		itimeto = funclib::gettimestamp();
-			
-		auto pid = std::this_thread::get_id();
+		
 		getgamehistory(itimefrom, itimeto, ipage);
 	}
 }