00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "stdafx.h"
00037 #include "SocketThreadManager.h"
00038
00039 #include "ErrorHandlerMacros.h"
00040 #include "OSManager.h"
00041
00042 #include "GenericCriticalSection.h"
00043 #include "GenericThread.h"
00044 #include "GenericEvent.h"
00045 #include "WaitList.h"
00046
00047 #include <objbase.h>
00048
00049 #ifdef _MEMORY_DEBUG
00050 #define new DEBUG_NEW
00051 #define malloc DEBUG_MALLOC
00052 static char THIS_FILE[] = __FILE__;
00053 #endif
00054
00055 KOMODIA_NAMESPACE_START
00056
00057 #define CSocketThreadManager_Class "CSocketThreadManager"
00058
00059
00060 #define THREADS_TIMEOUT 20000
00061
00062
00063 BOOL CSocketThreadManager::m_bRegisteredWindow=FALSE;
00064
00065
00066 CSocketThreadManager CSocketThreadManager::m_sManager(TRUE);
00067
00068 CSocketThreadManager::CSocketThreadManager(HINSTANCE hInstance) : CErrorHandler(),
00069 m_ulThreadCount(0),
00070 m_hInstance(hInstance),
00071 m_pThreadData(NULL),
00072 m_pCSection(NULL),
00073 m_bStaticClass(FALSE),
00074 m_bInitialized(FALSE),
00075 m_dwCleanTimeout(THREADS_TIMEOUT)
00076 {
00077 try
00078 {
00079
00080 SetName(CSocketThreadManager_Class);
00081
00082
00083 m_pCSection=COSManager::CreateCriticalSection();
00084 }
00085 ERROR_HANDLER("CSocketThreadManager")
00086 }
00087
00088 CSocketThreadManager::CSocketThreadManager(BOOL bStatic) : CErrorHandler(),
00089 m_bStaticClass(bStatic)
00090 {
00091 try
00092 {
00093
00094 SetName(CSocketThreadManager_Class);
00095 }
00096 ERROR_HANDLER("CSocketThreadManager")
00097 }
00098
00099 CSocketThreadManager::~CSocketThreadManager()
00100 {
00101 try
00102 {
00103
00104 if (m_bInitialized)
00105 Uninitialize();
00106
00107
00108 delete m_pCSection;
00109 }
00110 ERROR_HANDLER("~CSocketThreadManager")
00111 }
00112
00113 BOOL CSocketThreadManager::Initialize(unsigned long ulThreadCount,
00114 LPCSTR lpClassName)
00115 {
00116 try
00117 {
00118
00119 if (m_bInitialized)
00120 {
00121
00122 ReportError("Initialize","Already initialized!");
00123
00124
00125 return FALSE;
00126 }
00127
00128
00129 if (ulThreadCount>MAX_THREADS)
00130 {
00131
00132 ReportError("Initialize","Too many threads to spawn!");
00133
00134
00135 return FALSE;
00136 }
00137
00138
00139 if (!ulThreadCount)
00140 {
00141
00142 ReportError("Initialize","Can't have zero threads!");
00143
00144
00145 return FALSE;
00146 }
00147
00148
00149 m_ulThreadCount=ulThreadCount;
00150
00151
00152 return SpawnThreads(lpClassName);
00153 }
00154 ERROR_HANDLER_RETURN("Initialize",FALSE)
00155 }
00156
00157 BOOL CSocketThreadManager::Uninitialize()
00158 {
00159 try
00160 {
00161
00162 if (!m_bInitialized)
00163 return TRUE;
00164
00165
00166 if (m_bStaticClass)
00167
00168 UnregisterClass();
00169 else
00170
00171 CleanThreads(FALSE);
00172
00173
00174 m_bInitialized=FALSE;
00175
00176
00177 return TRUE;
00178 }
00179 ERROR_HANDLER_RETURN("Uninitialize",FALSE)
00180 }
00181
00182 BOOL CSocketThreadManager::SpawnThreads(LPCSTR lpClassName)
00183 {
00184 try
00185 {
00186
00187 if (!lpClassName)
00188 {
00189
00190 int iStringLength;
00191 iStringLength=strlen(CSocketThreadManager_Class);
00192
00193
00194 iStringLength+=50;
00195
00196
00197 std::auto_ptr<char> pString(new char[iStringLength]);
00198
00199
00200 DWORD dwThreadID;
00201 dwThreadID=GetCurrentThreadId();
00202
00203
00204 DWORD dwProcessID;
00205 dwProcessID=GetTickCount();
00206
00207
00208 sprintf(pString.get(),"%s_%lu_%lu",CSocketThreadManager_Class,
00209 GetCurrentThreadId(),
00210 GetTickCount());
00211
00212
00213
00214 if (!m_bRegisteredWindow)
00215 if (!RegisterClass(pString.get()))
00216 {
00217
00218 ReportError("SpawnThreads","Failed to register window!");
00219
00220
00221 return FALSE;
00222 }
00223
00224
00225 m_sClassName=pString.get();
00226 }
00227 else
00228 m_sClassName=lpClassName;
00229
00230
00231
00232 m_pThreadData=new ThreadData[m_ulThreadCount];
00233
00234
00235 for (int iCount=0;iCount<m_ulThreadCount;++iCount)
00236 {
00237 m_pThreadData[iCount].bFreeze=FALSE;
00238 m_pThreadData[iCount].pEvent=NULL;
00239 m_pThreadData[iCount].hInstance=NULL;
00240 m_pThreadData[iCount].hWindowHandle=NULL;
00241 m_pThreadData[iCount].iSocketCount=0;
00242 m_pThreadData[iCount].iTimeoutCount=0;
00243 m_pThreadData[iCount].pThread=NULL;
00244 m_pThreadData[iCount].pCSection=COSManager::CreateCriticalSection();
00245 m_pThreadData[iCount].pClass=this;
00246 }
00247
00248
00249 BOOL bError;
00250 bError=FALSE;
00251
00252
00253 CWaitList aList;
00254
00255
00256 for (int iCounter=0;
00257 iCounter<m_ulThreadCount;
00258 ++iCounter)
00259 {
00260
00261 m_pThreadData[iCounter].sClassName=m_sClassName;
00262
00263
00264 m_pThreadData[iCounter].pEvent=COSManager::CreateEvent();
00265
00266
00267 aList.AddObject(m_pThreadData[iCounter].pEvent,
00268 TRUE);
00269
00270
00271 m_pThreadData[iCounter].hInstance=m_hInstance;
00272
00273
00274 CreateExtendedData(m_pThreadData[iCounter].aExtension);
00275
00276
00277 m_pThreadData[iCounter].pThread=COSManager::CreateThread(SocketThread);
00278
00279
00280 if (!m_pThreadData[iCounter].pThread->GetThreadID())
00281 {
00282
00283 ReportError("SpawnThreads","Failed to create thread!");
00284
00285
00286 bError=TRUE;
00287
00288
00289 break;
00290 }
00291 else
00292
00293 m_pThreadData[iCounter].pThread->Start((LPVOID)&m_pThreadData[iCounter]);
00294 }
00295
00296
00297 DWORD dwTmp;
00298
00299 if (aList.Wait(TRUE,
00300 dwTmp,
00301 THREADS_TIMEOUT))
00302 {
00303
00304 ReportError("SpawnThreads","Timeout waiting for threads!");
00305
00306
00307 CleanThreads(TRUE);
00308
00309
00310 return FALSE;
00311 }
00312 else if (bError)
00313 {
00314
00315 CleanThreads(FALSE);
00316
00317
00318 return FALSE;
00319 }
00320 else
00321 {
00322
00323 m_bInitialized=TRUE;
00324
00325
00326 return TRUE;
00327 }
00328 }
00329 ERROR_HANDLER_RETURN("SpawnThreads",FALSE)
00330 }
00331
00332 DWORD CSocketThreadManager::SocketThread(LPVOID lpParameter)
00333 {
00334 try
00335 {
00336
00337 ThreadData* pData;
00338 pData=(ThreadData*)lpParameter;
00339
00340
00341 srand(GetTickCount()+(unsigned long)pData->pEvent+(unsigned long)pData->hWindowHandle);
00342
00343
00344 pData->hWindowHandle=CreateWindowEx(0,
00345 pData->sClassName.c_str(),
00346 SOCKET_WINDOW_NAME,
00347 WS_OVERLAPPED,
00348 0,
00349 0,
00350 0,
00351 0,
00352 0,
00353 NULL,
00354 pData->hInstance,
00355 NULL);
00356
00357
00358 pData->pEvent->Set();
00359
00360
00361 if (pData->hWindowHandle)
00362 {
00363
00364 MSG msg;
00365
00366 while (GetMessage(&msg,
00367 NULL,
00368 0,
00369 0))
00370 {
00371
00372 TranslateMessage(&msg);
00373
00374
00375 if (msg.message==WM_TIMER)
00376 {
00377
00378 CCriticalAutoRelease aRelease(pData->pCSection);
00379
00380
00381 TOMap::iterator aTheIterator;
00382 aTheIterator=pData->pMap.find(msg.wParam);
00383
00384
00385 if (aTheIterator!=pData->pMap.end())
00386 {
00387
00388 TimeoutData aData;
00389 aData=aTheIterator->second;
00390
00391
00392 if (aData.bClearTimeout)
00393 {
00394
00395 KillTimer(pData->hWindowHandle,
00396 msg.wParam);
00397
00398
00399 if (aData.pTimer)
00400 memset(aData.pTimer,
00401 0,
00402 sizeof(TimerID));
00403
00404
00405 pData->pMap.erase(aTheIterator);
00406
00407
00408 --pData->iTimeoutCount;
00409 }
00410
00411
00412 aRelease.Exit();
00413
00414
00415 try
00416 {
00417
00418 (*(aData.pTimeoutProc))(aData.pData);
00419 }
00420 ERROR_HANDLER_STATIC(CSocketThreadManager_Class,"SocketThread - Proc")
00421 }
00422 else
00423 {
00424
00425 aRelease.Exit();
00426
00427
00428 pData->pClass->ParseDispatchMessage(msg,
00429 pData);
00430 }
00431 }
00432 else
00433
00434 pData->pClass->ParseDispatchMessage(msg,
00435 pData);
00436 }
00437 }
00438 else
00439
00440 ReportStaticError(CSocketThreadManager_Class,"SocketThread","Failed to create window!");
00441
00442
00443 pData->pEvent->Set();
00444
00445
00446 return FALSE;
00447 }
00448 ERROR_HANDLER_STATIC_RETURN(CSocketThreadManager_Class,"SocketThread",TRUE)
00449 }
00450
00451 int CSocketThreadManager::GetMostAvailableThread()const
00452 {
00453 try
00454 {
00455
00456 int iStartPosition;
00457 iStartPosition=1;
00458
00459 int iIndex;
00460 iIndex=0;
00461
00462
00463 CCriticalAutoRelease aRelease(m_pCSection);
00464
00465
00466 while (iIndex<m_ulThreadCount &&
00467 m_pThreadData[iIndex].bFreeze)
00468 {
00469
00470 m_pThreadData[iIndex].bFreeze=FALSE;
00471
00472 ++iIndex;
00473 ++iStartPosition;
00474 }
00475
00476
00477 if (iIndex==m_ulThreadCount)
00478 return GetMostAvailableThread();
00479
00480
00481 for (int iCounter=iStartPosition;iCounter<m_ulThreadCount;++iCounter)
00482
00483 if (m_pThreadData[iCounter].iSocketCount+m_pThreadData[iCounter].iTimeoutCount<
00484 m_pThreadData[iIndex].iSocketCount+m_pThreadData[iIndex].iTimeoutCount &&
00485 m_pThreadData[iCounter].pThread->GetThreadID())
00486
00487 if (m_pThreadData[iCounter].bFreeze)
00488
00489 m_pThreadData[iCounter].bFreeze=FALSE;
00490 else
00491
00492 iIndex=iCounter;
00493
00494
00495 return iIndex+1;
00496 }
00497 ERROR_HANDLER_RETURN("GetMostAvailableThread",0)
00498 }
00499
00500 HWND CSocketThreadManager::GetWindowHandle(BOOL bTimeout)
00501 {
00502 try
00503 {
00504
00505 CCriticalAutoRelease aRelease(m_pCSection);
00506
00507
00508 int iIndex;
00509 iIndex=GetMostAvailableThread();
00510
00511
00512 if (!iIndex)
00513
00514 return 0;
00515
00516
00517 if (bTimeout)
00518 ++m_pThreadData[iIndex-1].iTimeoutCount;
00519 else
00520
00521 ++m_pThreadData[iIndex-1].iSocketCount;
00522
00523
00524 return m_pThreadData[iIndex-1].hWindowHandle;
00525 }
00526 ERROR_HANDLER_RETURN("GetWindowHandle",0)
00527 }
00528
00529 const CGenericThread* CSocketThreadManager::GetThreadByHWND(HWND hWindowHandle)const
00530 {
00531 try
00532 {
00533
00534 int iIndex;
00535 iIndex=GetIndexByHWND(hWindowHandle);
00536
00537
00538 if (!iIndex)
00539 return NULL;
00540
00541
00542 CCriticalAutoRelease aRelease(m_pCSection);
00543
00544
00545 return m_pThreadData[iIndex-1].pThread;
00546 }
00547 ERROR_HANDLER_RETURN("GetThreadByHWND",NULL)
00548 }
00549
00550 void CSocketThreadManager::DecreaseSocketCount(HWND hWindowHandle,
00551 BOOL bFreeze)
00552 {
00553 try
00554 {
00555
00556 int iIndex;
00557 iIndex=GetIndexByHWND(hWindowHandle);
00558
00559
00560 if (!iIndex)
00561 return;
00562
00563
00564 CCriticalAutoRelease aRelease(m_pCSection);
00565
00566
00567 if (m_pThreadData[iIndex-1].iSocketCount>0)
00568 {
00569 --m_pThreadData[iIndex-1].iSocketCount;
00570 m_pThreadData[iIndex-1].bFreeze=bFreeze;
00571 }
00572 }
00573 ERROR_HANDLER("DecreaseSocketCount")
00574 }
00575
00576 void CSocketThreadManager::DecreaseTimeoutCount(HWND hWindowHandle,
00577 BOOL bFreeze)
00578 {
00579 try
00580 {
00581
00582 int iIndex;
00583 iIndex=GetIndexByHWND(hWindowHandle);
00584
00585
00586 if (!iIndex)
00587 return;
00588
00589
00590 CCriticalAutoRelease aRelease(m_pCSection);
00591
00592
00593 if (m_pThreadData[iIndex-1].iTimeoutCount>0)
00594 {
00595 --m_pThreadData[iIndex-1].iTimeoutCount;
00596 m_pThreadData[iIndex-1].bFreeze=bFreeze;
00597 }
00598 }
00599 ERROR_HANDLER("DecreaseTimeoutCount")
00600 }
00601
00602 CSocketThreadManager::ThreadData* CSocketThreadManager::GetDataByHWND(HWND hHandle)const
00603 {
00604 try
00605 {
00606
00607 int iIndex;
00608 iIndex=GetIndexByHWND(hHandle);
00609
00610
00611 if (iIndex)
00612 return &m_pThreadData[iIndex-1];
00613 else
00614 return NULL;
00615 }
00616 ERROR_HANDLER_RETURN("GetDataByHWND",NULL)
00617 }
00618
00619 int CSocketThreadManager::GetIndexByHWND(HWND hHandle)const
00620 {
00621 try
00622 {
00623 for (int iCounter=0;iCounter<m_ulThreadCount;++iCounter)
00624 if (m_pThreadData[iCounter].hWindowHandle==hHandle)
00625
00626 return iCounter+1;
00627
00628
00629 return 0;
00630 }
00631 ERROR_HANDLER_RETURN("GetIndexByHWND",0)
00632 }
00633
00634 void CSocketThreadManager::CleanThreads(BOOL bError)
00635 {
00636 try
00637 {
00638
00639 CWaitList aList;
00640
00641
00642 if (m_pThreadData)
00643 {
00644
00645 int iCounter;
00646
00647
00648 for (iCounter=0;
00649 iCounter<m_ulThreadCount;
00650 ++iCounter)
00651
00652 if (m_pThreadData[iCounter].pThread->GetThreadID())
00653 {
00654
00655 PostThreadMessage(m_pThreadData[iCounter].pThread->GetThreadID(),
00656 WM_QUIT,
00657 0,
00658 0);
00659
00660
00661 if (bError)
00662
00663 DestroyWindow(m_pThreadData[iCounter].hWindowHandle);
00664 else if (m_pThreadData[iCounter].pEvent)
00665 aList.AddObject(m_pThreadData[iCounter].pEvent,TRUE);
00666 }
00667
00668
00669 if (bError)
00670
00671 Sleep(1000);
00672 else
00673 {
00674
00675 DWORD dwTmp;
00676
00677
00678 if (aList.Wait(TRUE,
00679 dwTmp,
00680 m_dwCleanTimeout))
00681 ReportError("CleanThreads","Timeout waiting for threads!");
00682 }
00683
00684
00685 for (iCounter=0;
00686 iCounter<m_ulThreadCount;
00687 ++iCounter)
00688 {
00689
00690 DeleteExtendedData(m_pThreadData[iCounter].aExtension);
00691
00692
00693 delete m_pThreadData[iCounter].pThread;
00694
00695
00696 delete m_pThreadData[iCounter].pCSection;
00697
00698
00699 delete m_pThreadData[iCounter].pEvent;
00700
00701
00702 if (!bError)
00703
00704 DestroyWindow(m_pThreadData[iCounter].hWindowHandle);
00705 }
00706
00707
00708 delete [] m_pThreadData;
00709 }
00710 }
00711 ERROR_HANDLER("CleanThreads")
00712 }
00713
00714 CSocketThreadManager::TimerID CSocketThreadManager::RegisterTimeout(int iMS,
00715 LPTimeoutProc pProc,
00716 LPVOID pData,
00717 BOOL bClearTimeout,
00718 HWND hHandle,
00719 TimerID* pTimer,
00720 LPTimeoutProc pDeleteProc)
00721 {
00722 TimerID aTimerID;
00723 aTimerID.iIndex=0;
00724
00725 try
00726 {
00727
00728 if (pTimer)
00729 memset(pTimer,0,sizeof(TimerID));
00730
00731 int iIndex;
00732
00733
00734 TimeoutData aData;
00735 aData.pTimeoutProc=pProc;
00736 aData.pData=pData;
00737 aData.bClearTimeout=bClearTimeout;
00738 aData.pTimer=pTimer;
00739 aData.pDeleteProc=pDeleteProc;
00740
00741
00742 CCriticalAutoRelease aRelease(m_pCSection);
00743
00744
00745 if (hHandle)
00746 {
00747
00748 iIndex=GetIndexByHWND(hHandle);
00749
00750
00751 if (!iIndex)
00752 {
00753
00754 ReportError("RegisterTimeout","Failed to find handle!");
00755
00756
00757 return aTimerID;
00758 }
00759 else
00760 --iIndex;
00761 }
00762 else
00763 {
00764
00765 iIndex=GetMostAvailableThread();
00766
00767
00768 if (!iIndex)
00769 {
00770
00771 ReportError("RegisterTimeout","Failed to find thread!");
00772
00773
00774 return aTimerID;
00775 }
00776
00777
00778 --iIndex;
00779 }
00780
00781
00782 unsigned int iTimerID;
00783 iTimerID=0;
00784
00785
00786 static int sTimerCounter=1000000;
00787
00788
00789 int iSetTimerID;
00790 iSetTimerID=sTimerCounter++;
00791
00792
00793 CCriticalAutoRelease aRelease2(m_pThreadData[iIndex].pCSection);
00794
00795
00796 ++m_pThreadData[iIndex].iTimeoutCount;
00797
00798
00799 m_pThreadData[iIndex].pMap.insert(TOMap::value_type(iSetTimerID,aData));
00800
00801
00802 aRelease2.Exit();
00803 aRelease.Exit();
00804
00805
00806 iTimerID=SetTimer(m_pThreadData[iIndex].hWindowHandle,
00807 iSetTimerID,
00808 iMS,
00809 NULL);
00810
00811
00812 if (!iTimerID)
00813 {
00814 {
00815
00816
00817 CCriticalAutoRelease aRelease2(m_pThreadData[iIndex].pCSection);
00818
00819
00820 --m_pThreadData[iIndex].iTimeoutCount;
00821
00822
00823 m_pThreadData[iIndex].pMap.erase(iSetTimerID);
00824 }
00825
00826
00827 ReportError("RegisterTimeout","Failed to create the timer!");
00828
00829
00830 return aTimerID;
00831 }
00832
00833
00834 aTimerID.iTimerID=iSetTimerID;
00835 aTimerID.iIndex=iIndex+1;
00836 aTimerID.iMS=iMS;
00837
00838
00839 if (pTimer)
00840 memcpy(pTimer,&aTimerID,sizeof(aTimerID));
00841
00842
00843 return aTimerID;
00844 }
00845 ERROR_HANDLER_RETURN("RegisterTimeout",aTimerID)
00846 }
00847
00848 BOOL CSocketThreadManager::RemoveTimeout(TimerID& aTimerID,
00849 BOOL bInvokeDeleteProc)
00850 {
00851
00852 if (!aTimerID.iIndex)
00853 {
00854
00855 ReportError("RemoveTimeout","Received invalid TimerID");
00856
00857
00858 return FALSE;
00859 }
00860
00861 try
00862 {
00863
00864 if (!KillTimer(m_pThreadData[aTimerID.iIndex-1].hWindowHandle,
00865 aTimerID.iTimerID))
00866
00867 ReportErrorOS("RemoveTimeout","Failed to delete timer!");
00868
00869 {
00870
00871 CCriticalAutoRelease aRelease(m_pThreadData[aTimerID.iIndex-1].pCSection);
00872
00873
00874 if (!bInvokeDeleteProc)
00875
00876 m_pThreadData[aTimerID.iIndex-1].pMap.erase(aTimerID.iTimerID);
00877 else
00878 {
00879
00880 TOMap::iterator aIterator;
00881 aIterator=m_pThreadData[aTimerID.iIndex-1].pMap.find(aTimerID.iTimerID);
00882
00883
00884 if (aIterator!=m_pThreadData[aTimerID.iIndex-1].pMap.end())
00885 {
00886
00887 if (aIterator->second.pDeleteProc)
00888
00889 (*aIterator->second.pDeleteProc)(aIterator->second.pData);
00890
00891
00892 m_pThreadData[aTimerID.iIndex-1].pMap.erase(aIterator);
00893 }
00894 else
00895
00896 ReportError("RemoveTimeout","Failed to find data!");
00897 }
00898
00899
00900 --m_pThreadData[aTimerID.iIndex-1].iTimeoutCount;
00901
00902
00903 aTimerID.iIndex=0;
00904 aTimerID.iMS=0;
00905 aTimerID.iTimerID=0;
00906 }
00907
00908
00909 return TRUE;
00910 }
00911 ERROR_HANDLER_RETURN("RemoveTimeout",FALSE)
00912 }
00913
00914 BOOL CSocketThreadManager::UnregisterClass()
00915 {
00916 if (!m_bRegisteredWindow)
00917 return TRUE;
00918
00919 try
00920 {
00921
00922 m_bRegisteredWindow=!::UnregisterClass(m_sClassName.c_str(),
00923 m_hInstance);
00924
00925
00926 return !m_bRegisteredWindow;
00927 }
00928 ERROR_HANDLER_RETURN("UnregisterClass",FALSE)
00929 }
00930
00931 BOOL CSocketThreadManager::RegisterClass(LPCSTR lpClassName)
00932 {
00933
00934 if (m_bRegisteredWindow)
00935 return TRUE;
00936
00937 try
00938 {
00939 WNDCLASS wc;
00940
00941
00942
00943
00944 wc.style = 0;
00945 wc.lpfnWndProc = (WNDPROC)DefWindowProc;
00946
00947 wc.cbClsExtra = 0;
00948 wc.cbWndExtra = 0;
00949 wc.hIcon = NULL;
00950 wc.hInstance = m_hInstance;
00951 wc.hCursor = NULL;
00952 wc.hbrBackground = NULL;
00953 wc.lpszMenuName = NULL;
00954 wc.lpszClassName = lpClassName ;
00955
00956
00957 m_bRegisteredWindow=::RegisterClass(&wc)!=0;
00958
00959
00960 return m_bRegisteredWindow;
00961 }
00962 ERROR_HANDLER_RETURN("RegisterClass",FALSE)
00963 }
00964
00965 BOOL CSocketThreadManager::ReSetTimeout(const TimerID &rTimerID)
00966 {
00967
00968 if (!rTimerID.iTimerID)
00969 {
00970
00971 ReportError("ReSetTimeout","Someone send an empty TimerID!");
00972
00973
00974 return FALSE;
00975 }
00976
00977 try
00978 {
00979
00980 int iResult;
00981 iResult=SetTimer(m_pThreadData[rTimerID.iIndex-1].hWindowHandle,
00982 rTimerID.iTimerID,
00983 rTimerID.iMS,
00984 NULL);
00985
00986
00987 if (!iResult)
00988 ReportError("ReSetTimeout","Failed to reset the timeout!");
00989
00990
00991 return iResult!=0;
00992 }
00993 ERROR_HANDLER_RETURN("ReSetTimeout",FALSE)
00994 }
00995
00996 const std::string& CSocketThreadManager::GetClassName()const
00997 {
00998 return m_sClassName;
00999 }
01000
01001 BOOL CSocketThreadManager::IsInitialized()const
01002 {
01003 return m_bInitialized;
01004 }
01005
01006 unsigned long CSocketThreadManager::GetNumberOfThreads()const
01007 {
01008 return m_ulThreadCount;
01009 }
01010
01011 void CSocketThreadManager::ParseDispatchMessage(const MSG& rMsg,
01012 ThreadData* pData)
01013 {
01014
01015 DispatchMessage(&rMsg);
01016 }
01017
01018 void CSocketThreadManager::CreateExtendedData(ThreadDataExtend& rData)
01019 {
01020 }
01021
01022 void CSocketThreadManager::DeleteExtendedData(ThreadDataExtend& rData)
01023 {
01024 }
01025
01026 void CSocketThreadManager::SetCleanTimeout(DWORD dwTimeout)
01027 {
01028 m_dwCleanTimeout=dwTimeout;
01029 }
01030
01031 KOMODIA_NAMESPACE_END