<div dir="ltr"><div><div><div>Hey rusty,
</div></div></div><div><br></div><div>Sorry for yestarday's email, I was drunk and somewhat clicked send when it's incomplete...</div><div><br></div><div>So here's the idea:</div><div><br></div><div> struct io_service {</div>
<div> struct sock_events *sevents;</div><div> };</div><div><br></div><div> /* ... your functions, new_listener() and so on */</div><div> /* Creates a thread */</div><div> void start_service(struct io_service *service);</div>
<div> /* Blocks until all polling is done. */</div><div> void run_service(struct io_service *service);</div><div><br></div><div><br></div><div>You then would call some functions like:</div><div> add_listener(&my_io_service, host, port, ...);</div>
<div><br></div><div>Then on main():</div><div> for (int i = 0; i < nthreads; i++)</div><div> start_service(&my_io_service);</div><div> run_service(&my_io_service);</div><div><br></div>
<div>Or we could hide the implementation of io_service in the source file and work with that.</div><div><br></div><div>Lemme know what you think</div><div><br></div><div>Thanks!</div><div>Allan</div></div>