1 /*************************************************************************** 2 * * 3 * This program is free software; you can redistribute it and/or modify * 4 * it under the terms of the GNU General Public License as published by * 5 * the Free Software Foundation; either version 2 of the License, or * 6 * (at your option) any later version. * 7 * * 8 *************************************************************************** 9 * net/radaptor.h 10 * 11 * Allows resolver to be used with the IO engines. 12 * (c) 2005-2007 Murat Deligonul 13 */ 14 15 #ifndef __NET_RADAPTOR_H 16 #define __NET_RADAPTOR_H 17 18 #include "net/resolver.h" 19 #include "io/engine.h" 20 #include "io/event.h" 21 #include "io/pollable.h" 22 23 namespace net { 24 25 class radaptor : public io::pollable 26 { 27 private: 28 resolver& r; 29 io::engine& e; 30 31 public: radaptor(resolver & _r,io::engine & _e)32 radaptor(resolver &_r, io::engine &_e) : r(_r), e(_e) { 33 set_fd(r.fifo_reader_fd()); 34 e.add(this, io::EVENT_READ); 35 } 36 ~radaptor()37 ~radaptor() { 38 e.release(this); 39 } 40 41 /* 'pollable' interface */ event_callback(int)42 virtual int event_callback(int) { 43 r.process_results(); 44 return 0; 45 } 46 }; 47 48 } /* namespace net */ 49 #endif /* __NET_RESOLVER_H */ 50 51