MCPcopy Create free account
hub / github.com/SOUI2/soui / HelperThread

Method HelperThread

demo/httpsvr/GenericServer.cpp:664–697  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

662
663
664UINT __stdcall CGenericServer::HelperThread(LPVOID pParam)
665{
666 CGenericServer *pGenericServer = (CGenericServer*)pParam;
667 HANDLELIST::iterator it;
668
669 SetEvent(pGenericServer->ThreadLaunchedEvent);
670
671 for(;;)
672 {
673 if(WaitForSingleObject(pGenericServer->ShutdownEvent, TICK) == WAIT_TIMEOUT)
674 {
675 EnterCriticalSection(&pGenericServer->_cs);
676 while(pGenericServer->HandleList.size())
677 {
678 HANDLE h = pGenericServer->HandleList.front();
679 DWORD n = WaitForSingleObject(h, THREADKILL_TO);
680 if(n == WAIT_TIMEOUT)
681 {
682 pGenericServer->LogMessage(LOGFILENAME, _T("WaitForSingleObject(...) timed out"), _T("HelperThread"));
683 if(!TerminateThread(h, THREADEXIT_SUCCESS))
684 pGenericServer->LogMessage(LOGFILENAME, _T("TerminateThread(.h.) failure, probably it is already terminated"), _T("HelperThread"), GetLastError());
685 }
686 CloseHandle(h);
687 pGenericServer->HandleList.pop_front();
688 }
689 LeaveCriticalSection(&pGenericServer->_cs);
690 }
691 else
692 return THREADEXIT_SUCCESS;
693
694 }
695
696 return THREADEXIT_SUCCESS;
697}
698
699
700

Callers

nothing calls this directly

Calls 4

GetLastErrorFunction · 0.85
LogMessageMethod · 0.80
pop_frontMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected