Now I'm in such a situation that there is a group of predefined tasks for multiple clients to do(any client can take any task). When a client connects to the server, server choose a task from the uncompleted tasks and send it to the client --- job on the server side is quite easy. It takes a while for the client to finish the task and send the result back to the server.
Since a task should be sent to only one client, server should process requests in a serialized way. Now I have two plans to do it: create a thread for each client connection and all the threads take turns accessing the task pool, or use epoll listening on all the connection and process for each event of clients.
Which one is better for the job? Or is there any other ideas? The server will be run on a multi-core machine.