int SlaveAgent::readData(){ struct WordPair wordPair; memset(&wordPair, 0 , sizeof(struct WordPair)); int n = m_TcpSocket.read( &wordPair, sizeof(struct WordPair) ); if( n < 0){ perror("In SlaveAgent::readData() read error!\n"); return FAILED; }else if(n == 0){ *(m_pJobCount) -= 1; if( *m_pJobCount == 0){ Epoll::getInstance()->setEndTime(); printWordMap(); std::cout << "spend time:" << Epoll::getInstance()->getSpendTime() <<"us"<<std::endl; } m_TcpSocket.close(); delete this; }else if( n > 0 ){ std::string word; word = wordPair.word; (*m_pWordCountBuffer)[ word ] += wordPair.count; } return SUCCESSFUL; }
bool Console::Cmd_Nouns(int argc, const char **argv) { if (argc != 1) { debugPrintf("Usage: %s\n", argv[0]); return true; } debugPrintf("Nouns in alphabetical order:\n"); printWordMap(_engine->_nouns); return true; }