<div dir="ltr"><br><br><div class="gmail_quote">On Fri, Dec 7, 2012 at 8:25 PM, Allan Ference <span dir="ltr"><<a href="mailto:f.fallen45@gmail.com" target="_blank">f.fallen45@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div class="h5"><br><br><div class="gmail_quote">On Fri, Dec 7, 2012 at 8:09 PM, Allan Ference <span dir="ltr"><<a href="mailto:f.fallen45@gmail.com" target="_blank">f.fallen45@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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><span><font color="#888888"><div>
Allan</div></font></span></div>
</blockquote></div><br></div></div>Well, missed something, we could also make just 1 function instead of 2 for the service,<div><br></div><div> pthread_t threads[2];</div><div> for (int i = 0; i < 2; i++)</div>
<div> if (pthread_create(&threads[i], NULL, &run_service, &my_io_service) != 0)</div>
<div> abort();</div><div> for (int i = 0; i < 2; i++)</div><div> pthread_join(&threads[i], NULL);<br>
<div><br></div></div><div>Allan</div></div></blockquote></div>Re-sending to list. >_>
</div>