On Tue, Nov 20, 2012 at 03:09:23PM +0100, Adam D. Ruppe wrote: > On Tuesday, 20 November 2012 at 04:26:02 UTC, Andrei Alexandrescu > wrote: > >We sorely need a server expert on board with the time and > >inclination to write a good server-side networking framework. > > I agree with this but it really should be generic; working at > probably the file descriptor level, so we can do whatever protocols > along with files, pipes, ... and ideally, any kind of injected > event. I'd really like it if we could run one event loop and be able > to do keyboard/joystick input, timers, GUI, threads, etc., including > third party libraries, as well as networking. (Combining two > different event loops is a pain in the butt.)
The event loop itself should be a generic component in Phobos, not specific to anything else. It should work at the file descriptor level, perhaps even combining with signal handling (using the self-pipe trick), and handle timers and scheduled events as well. Everything else should be pluggable into this generic module. I have written such things before in C/C++, but in D this will be much easier to implement, thanks to delegates (which make writing event-loop based programs so much less painful). Having a standard event loop will make it much less painful to integrate many components together in a seamless way. Combining two event loops, as Adam says, is a royal pain in the neck. Making the generic event loop a Phobos standard will eliminate this problem. > I have an implementation in mind (I'd use select() because I don't > know libev, but we should be able to change that without changing > the interface)... The interface should be generic enough that you don't have to worry about whether select or poll (or whatever the windows equivalent is) is used. I think it's a good idea to implement the select version first, as that's generic across Posixes, whereas libev is Linux-specific IIRC. T -- 2+2=4. 2*2=4. 2^2=4. Therefore, +, *, and ^ are the same operation.
