void test(int size) { ThreadPool pool; pool.init(size); //Task* task; for(int i=0; i<n; i++) { testTask[i] = std::bind(run, i); //task = new Task(); //*task = std::bind(run, i); pool.add(&testTask[i]); //pool.add(task); } pool.start(); while(1) sleep(1); }
bool start() { _pool.start(); sockaddr_in clientaddr; socklen_t nSize = sizeof(clientaddr); int clientSock; while(true) { if(-1 == (clientSock = accept(_host_socket, (struct sockaddr*) &clientaddr, &nSize))) { LogError(strerror(errno)); break; //continue; } _pool.add(CreateTask<WorkerThread,int, const IRequestHandler&>(clientSock, _reqHandler)); //_response(clientSock); //_closesocket(clientSock); } return true; }