2006-07-19 12:51:21 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
2006-12-15 22:18:59 +00:00
|
|
|
* InspIRCd: (C) 2002-2007 InspIRCd Development Team
|
|
|
|
* See: http://www.inspircd.org/wiki/index.php/Credits
|
2006-07-19 12:51:21 +00:00
|
|
|
*
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
2006-12-15 22:18:59 +00:00
|
|
|
*/
|
2006-07-19 12:51:21 +00:00
|
|
|
|
|
|
|
#ifndef __SOCKETENGINE_KQUEUE__
|
|
|
|
#define __SOCKETENGINE_KQUEUE__
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
#include "inspircd_config.h"
|
|
|
|
#include "globals.h"
|
|
|
|
#include "inspircd.h"
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/event.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include "socketengine.h"
|
|
|
|
|
2006-08-11 12:15:03 +00:00
|
|
|
class InspIRCd;
|
|
|
|
|
2006-08-12 01:13:40 +00:00
|
|
|
/** A specialisation of the SocketEngine class, designed to use FreeBSD kqueue().
|
|
|
|
*/
|
2006-07-19 12:51:21 +00:00
|
|
|
class KQueueEngine : public SocketEngine
|
|
|
|
{
|
|
|
|
private:
|
2006-08-12 01:13:40 +00:00
|
|
|
/** These are used by kqueue() to hold socket events
|
|
|
|
*/
|
|
|
|
struct kevent ke_list[MAX_DESCRIPTORS];
|
|
|
|
/** This is a specialised time value used by kqueue()
|
|
|
|
*/
|
|
|
|
struct timespec ts;
|
2006-07-19 12:51:21 +00:00
|
|
|
public:
|
2006-08-12 01:13:40 +00:00
|
|
|
/** Create a new KQueueEngine
|
|
|
|
* @param Instance The creator of this object
|
|
|
|
*/
|
2006-08-11 12:15:03 +00:00
|
|
|
KQueueEngine(InspIRCd* Instance);
|
2006-08-12 01:13:40 +00:00
|
|
|
/** Delete a KQueueEngine
|
|
|
|
*/
|
2006-07-19 12:51:21 +00:00
|
|
|
virtual ~KQueueEngine();
|
2006-08-18 01:08:14 +00:00
|
|
|
virtual bool AddFd(EventHandler* eh);
|
2006-07-19 12:51:21 +00:00
|
|
|
virtual int GetMaxFds();
|
|
|
|
virtual int GetRemainingFds();
|
2006-08-18 01:08:14 +00:00
|
|
|
virtual bool DelFd(EventHandler* eh);
|
2006-08-18 10:07:22 +00:00
|
|
|
virtual int DispatchEvents();
|
2006-07-19 12:51:21 +00:00
|
|
|
virtual std::string GetName();
|
2006-10-30 18:45:04 +00:00
|
|
|
virtual void WantWrite(EventHandler* eh);
|
2006-07-19 12:51:21 +00:00
|
|
|
};
|
|
|
|
|
2006-08-12 01:13:40 +00:00
|
|
|
/** Creates a SocketEngine
|
|
|
|
*/
|
2006-07-19 12:51:21 +00:00
|
|
|
class SocketEngineFactory
|
|
|
|
{
|
|
|
|
public:
|
2006-08-12 01:13:40 +00:00
|
|
|
/** Create a new instance of SocketEngine based on KQueueEngine
|
|
|
|
*/
|
2006-08-18 18:08:56 +00:00
|
|
|
SocketEngine* Create(InspIRCd* Instance) { return new KQueueEngine(Instance); }
|
2006-07-19 12:51:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|