Serialized task distribution: use thread or epoll?

Posted by hpsmouse on Stack Overflow See other posts from Stack Overflow or by hpsmouse
Published on 2010-06-01T12:39:19Z Indexed on 2010/06/01 12:43 UTC
Read the original article Hit count: 196

Filed under:
|

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. 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.

© Stack Overflow or respective owner

Related posts about multithreading

Related posts about networking