/* */ #ifndef _D_PORT_EVENT_POLL_H_ #define _D_PORT_EVENT_POLL_H_ #include "EventPoll.h" #ifdef HAVE_PORT_H # include #endif // HAVE_PORT_H #include #include "Event.h" #ifdef ENABLE_ASYNC_DNS # include "AsyncNameResolver.h" #endif // ENABLE_ASYNC_DNS namespace aria2 { class Logger; class PortEventPoll : public EventPoll { private: class KSocketEntry; typedef Event KEvent; typedef CommandEvent KCommandEvent; typedef ADNSEvent KADNSEvent; typedef AsyncNameResolverEntry KAsyncNameResolverEntry; friend class AsyncNameResolverEntry; struct A2PortEvent { int events; KSocketEntry* socketEntry; }; class KSocketEntry: public SocketEntry { public: KSocketEntry(sock_t socket); A2PortEvent getEvents(); }; friend int accumulateEvent(int events, const KEvent& event); private: std::deque > socketEntries_; #ifdef ENABLE_ASYNC_DNS std::deque > nameResolverEntries_; #endif // ENABLE_ASYNC_DNS int port_; size_t portEventsSize_; port_event_t* portEvents_; static const size_t PORT_EVENTS_SIZE = 1024; Logger* logger_; bool addEvents(sock_t socket, const KEvent& event); bool deleteEvents(sock_t socket, const KEvent& event); bool addEvents(sock_t socket, Command* command, int events, const SharedHandle& rs); bool deleteEvents(sock_t socket, Command* command, const SharedHandle& rs); public: PortEventPoll(); bool good() const; virtual ~PortEventPoll(); virtual void poll(const struct timeval& tv); virtual bool addEvents(sock_t socket, Command* command, EventPoll::EventType events); virtual bool deleteEvents(sock_t socket, Command* command, EventPoll::EventType events); #ifdef ENABLE_ASYNC_DNS virtual bool addNameResolver(const SharedHandle& resolver, Command* command); virtual bool deleteNameResolver (const SharedHandle& resolver, Command* command); #endif // ENABLE_ASYNC_DNS static const int IEV_READ = POLLIN; static const int IEV_WRITE = POLLOUT; static const int IEV_ERROR = POLLERR; static const int IEV_HUP = POLLHUP; }; } // namespace aria2 #endif // _D_PORT_EVENT_POLL_H_