Hey,
I'm looking to implement a pretty scalable client-server program.
I look into 3 patterns, and my conclustion were :
Reactor - pretty efficient but i have 2 concerns : 1. doesn't take advantage of multipreccosor machine (it's basically single threaded) 2. if one of the hooking methods are blocking, the entire application is blocked. 3. the programmer is resbonsible of dividing the main thread time between all handle request (while im multi-threading programs, the operatin system is the one responsible for the time slice mechanism )
Leader/followers - 1. attends the reactor blocking problem, with every waiting thread possibly becoming the leader , and waiting on the handle_set. 2. can use multipreccosor machine pretty nice, if for example i setup thread pool with the number of processor as the thread count.
but a problem arrise here too , what happens if all the thread are blocked ? again the application is blocked. and also not deviding proportional time to each handle, may cause kind of starvation.
Proactor - attends all the blocing problem of the previous 2 by initiating all the procedures as asynchronous. however incorporates a big complexity problem. however, it made me think ? how Windows launch a new async function ? by creating new thread ? cause if that's the case, then i didn't to anything useful what so ever.
And my main question - as far i understand Procator pattern can efficienly be implement in windows using completion ports... i'm not sure i totally get how is it suppose to work.
am i setting 1 completion port, linking all my handles (files,sockets etc..) to it , and launching couple threads (let's say equivalent to the number of cpu) who will constatnly read from that completion port ?
Further explanation would be great.