|
|||
|
|||
|
00001 /* +------------------------------------+ 00002 * | Inspire Internet Relay Chat Daemon | 00003 * +------------------------------------+ 00004 * 00005 * InspIRCd: (C) 2002-2008 InspIRCd Development Team 00006 * See: http://www.inspircd.org/wiki/index.php/Credits 00007 * 00008 * This program is free but copyrighted software; see 00009 * the file COPYING for details. 00010 * 00011 * --------------------------------------------------- 00012 */ 00013 00014 #ifndef __SOCKETENGINE_POLL__ 00015 #define __SOCKETENGINE_POLL__ 00016 00017 #include <vector> 00018 #include <string> 00019 #include <map> 00020 #include "inspircd_config.h" 00021 #include "globals.h" 00022 #include "inspircd.h" 00023 #include "socketengine.h" 00024 #ifndef __USE_XOPEN 00025 #define __USE_XOPEN /* fuck every fucking OS ever made. needed by poll.h to work.*/ 00026 #endif 00027 #include <poll.h> 00028 00029 class InspIRCd; 00030 00033 class PollEngine : public SocketEngine 00034 { 00035 private: 00038 struct pollfd events[MAX_DESCRIPTORS]; 00039 public: 00042 std::map<int, unsigned int> fd_mappings; 00046 PollEngine(InspIRCd* Instance); 00049 virtual ~PollEngine(); 00050 virtual bool AddFd(EventHandler* eh); 00051 virtual EventHandler* GetRef(int fd); 00052 virtual int GetMaxFds(); 00053 virtual int GetRemainingFds(); 00054 virtual bool DelFd(EventHandler* eh, bool force = false); 00055 virtual int DispatchEvents(); 00056 virtual std::string GetName(); 00057 virtual void WantWrite(EventHandler* eh); 00058 }; 00059 00062 class SocketEngineFactory 00063 { 00064 public: 00067 SocketEngine* Create(InspIRCd* Instance) { return new PollEngine(Instance); } 00068 }; 00069 00070 #endif