Hello Ladies and Gents,
A little help please.
I am designing a stateless server that will have the following functionality:
- Client submits a job to the server.
- Client is blocked while the server tries to perform the job.
- The server will spawn one or multiple threads to perform the job.
- The job either finishes, times out or fails.
- The appropriate response (based on the outcome) is created, the client is unblocked and the response is handed off to the client.
Here is what I have thought of so far.
- Client submits a job to the server.
- The server assigns an ID to the job, places the job on a Queue and then places the Client on an another queue (where it will be blocked).
- Have a thread pool that will execute the job, fetch the result and appropriately create the response.
- Based on ID, pick the client out of the queue (thereby unblocking it), give it the response and send it off.
Steps 1,3,4 seems quite straight forward however any ideas about how to put the client in a queue and then block it. Also, any pointers that would help me design this puppy would be appreciated.
Cheers