o2on svn commit
o2on-****@lists*****
2008年 3月 23日 (日) 09:23:34 JST
Revision: 64 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=o2on&view=rev&rev=64 Author: laxmi Date: 2008-03-23 09:23:33 +0900 (Sun, 23 Mar 2008) Log Message: ----------- FIX:çµäºå¦çã«ãããæéãå¹³å2ç§ç縮 詳細:å¾ æ©é¢æ°ãSleepããWaitForSingleObjectã¸å¤æ´ Modified Paths: -------------- branches/BRANCH_0043/o2on/src.o2on/O2DatDB.cpp branches/BRANCH_0043/o2on/src.o2on/O2DatDB.h branches/BRANCH_0043/o2on/src.o2on/O2LagQueryQueue.h Modified: branches/BRANCH_0043/o2on/src.o2on/O2DatDB.cpp =================================================================== --- branches/BRANCH_0043/o2on/src.o2on/O2DatDB.cpp 2008-03-20 13:12:33 UTC (rev 63) +++ branches/BRANCH_0043/o2on/src.o2on/O2DatDB.cpp 2008-03-23 00:23:33 UTC (rev 64) @@ -1312,6 +1312,7 @@ return; UpdateThreadLoop = true; + StopSignal.Off(); UpdateThreadHandle = (HANDLE)_beginthreadex( NULL, 0, StaticUpdateThread, (void*)this, 0, NULL); } @@ -1322,6 +1323,8 @@ if (!UpdateThreadHandle) return; UpdateThreadLoop = false; + StopSignal.On(); + //Join WaitForSingleObject(UpdateThreadHandle, INFINITE); CloseHandle(UpdateThreadHandle); @@ -1366,6 +1369,6 @@ CLEAR_WORKSET; //TRACEA("+++++ UPDATE +++++\n"); } - Sleep(3000); + StopSignal.Wait(3000); } } Modified: branches/BRANCH_0043/o2on/src.o2on/O2DatDB.h =================================================================== --- branches/BRANCH_0043/o2on/src.o2on/O2DatDB.h 2008-03-20 13:12:33 UTC (rev 63) +++ branches/BRANCH_0043/o2on/src.o2on/O2DatDB.h 2008-03-23 00:23:33 UTC (rev 64) @@ -13,10 +13,10 @@ #include "sqlite3.h" #include "sha.h" #include "O2Logger.h" +#include "event.h" - struct O2DatRec { hashT hash; @@ -61,6 +61,7 @@ Mutex UpdateQueueLock; HANDLE UpdateThreadHandle; bool UpdateThreadLoop; + EventObject StopSignal; protected: void log(sqlite3 *db); Modified: branches/BRANCH_0043/o2on/src.o2on/O2LagQueryQueue.h =================================================================== --- branches/BRANCH_0043/o2on/src.o2on/O2LagQueryQueue.h 2008-03-20 13:12:33 UTC (rev 63) +++ branches/BRANCH_0043/o2on/src.o2on/O2LagQueryQueue.h 2008-03-23 00:23:33 UTC (rev 64) @@ -27,6 +27,7 @@ typedef std::map<hashT,O2Key>::iterator O2KeyMapIt; bool Active; + EventObject StopSignal; HANDLE ThreadHandle; O2KeyMap queries; O2Logger *Logger; @@ -105,6 +106,7 @@ { if (!ThreadHandle) { Active = true; + StopSignal.Off(); ThreadHandle = (HANDLE)_beginthreadex(NULL, 0, StaticThread, (void*)this, 0, NULL); } } @@ -113,6 +115,9 @@ { if (ThreadHandle) { Active = false; + //note:SignalObjectAndWaitÖÌûªðatomicÉs¦é½ßKØ + StopSignal.On(); + //Join WaitForSingleObject(ThreadHandle, INFINITE); CloseHandle(ThreadHandle); ThreadHandle = NULL; @@ -163,7 +168,7 @@ it = queries.erase(it); } Unlock(); - Sleep(2500); + StopSignal.Wait(2500); } } };