.h
#define Thread_count_all 16
xxxxxClass:
CWininetHttp *m_HttpList[Thread_count_all];
char *m_itemToSendStrList[Thread_count_all];
static HANDLE m_handler[Thread_count_all];//创建几个http线程用在发送,主要耗时在这里
static HANDLE m_hl[Thread_count_all];
typedef struct tag_LogRecordIndex {
int index;
xxxxxClass *pThis;
} LogRecordIndex;
.cpp
xxxxxClass
xxxxxClass::xxxxxClass()
{
for (int i = 0; i < Thread_count_all; i++)
{
m_HttpList[i] = new CWininetHttp();
m_itemToSendStrList[i] = new char[1024 * SEND_LOG_SIZE];
memset(m_itemToSendStrList[i], 0x00, sizeof(char)* 1024 * SEND_LOG_SIZE);
}
StartAllWorkThread();
}
void xxxxxClass::StartAllWorkThread()
{
for (int i = 0; i < Thread_count_all; i++)
{
LogRecordIndex *couple = (LogRecordIndex *)alloca(sizeof(LogRecordIndex));
couple->index = i;
couple->pThis = this;
m_handler[i] = CreateEvent(NULL, false, false, NULL);
m_hl[i] = CreateThread(NULL, 0, ToLogWepUrl, (void *)couple, 0, NULL);
}
}
DWORD WINAPI xxxxxClass::ToLogWepUrl(LPVOID pm)
{
LogRecordIndex *couple = (LogRecordIndex*)pm;
int tmp = couple->index;
CLogRecord *pThis = couple->pThis;
while (true)
{
Sleep(50);
}
return 0;
}