void NetworkManager::Run() { int threadId; struct epoll_event events[100]; int numOfEvent, n; g_networkThreadCountLock.Lock(); threadId = g_networkThreadCount++; g_networkThreadCountLock.Unlock(); for(;;) { numOfEvent = epoll_wait(m_epollFdList[threadId], m_epollEvent2DList[threadId], 100, 2000); //printf("NW thread %d\n", threadId); if(numOfEvent < 0){ // critical error fprintf(stderr, "[ERROR] epoll_wait() ERROR : %s\n", strerror(errno)); exit(1); } if(numOfEvent == 0) { continue; } //printf("NT %d activated\n", TC); OnEvent(numOfEvent, threadId); } close(m_serverFd); for(int i=0; i<NETWORK_THREAD_NUM; i++) close(m_epollFdList[i]); }
void SingletonReleaseTextVector() { g_SpinLockTextVec.Lock(); if (g_pTextVec) { delete g_pTextVec; g_pTextVec = 0; } g_SpinLockTextVec.Unlock(); }
void SingletonReleaseHashTable() { g_SpinLockHashTable.Lock(); if (g_pObjHash) { delete g_pObjHash; g_pObjHash = 0; } g_SpinLockHashTable.Unlock(); }
HashType * SingletonGetHashTable() { if (!g_pObjHash) { g_SpinLockHashTable.Lock(); if (!g_pObjHash) g_pObjHash = new HashType; g_SpinLockHashTable.Unlock(); } return g_pObjHash; }
TextBufVecType * SingletonGetTextVector() { if (!g_pTextVec) { g_SpinLockTextVec.Lock(); if (!g_pTextVec) g_pTextVec = new TextBufVecType; g_SpinLockTextVec.Unlock(); } return g_pTextVec; }