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