From 3752b3f59d5216d7dc6221a361efc76b9ad2273d Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 23 Jan 2014 19:17:22 -0500 Subject: New socketengine stuff: Use vectors that grow as necessary instead of mass allocating everything at once Rework poll engine logic to make sense --- include/socketengine.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'include/socketengine.h') diff --git a/include/socketengine.h b/include/socketengine.h index 4a2285a98..072ed9bde 100644 --- a/include/socketengine.h +++ b/include/socketengine.h @@ -230,13 +230,14 @@ class CoreExport EventHandler : public classbase */ class CoreExport SocketEngine { + /** Reference table, contains all current handlers + **/ + std::vector ref; + protected: /** Current number of descriptors in the engine */ size_t CurrentSetSize; - /** Reference table, contains all current handlers - */ - EventHandler** ref; /** List of handlers that want a trial read/write */ std::set trials; @@ -251,6 +252,18 @@ class CoreExport SocketEngine virtual void OnSetEvent(EventHandler* eh, int old_mask, int new_mask) = 0; void SetEventMask(EventHandler* eh, int value); + + /** Add an event handler to the base socket engine. AddFd(EventHandler*, int) should call this. + */ + bool AddFd(EventHandler* eh); + + template + void ResizeDouble(std::vector& vect) + { + if (CurrentSetSize > vect.size()) + vect.resize(vect.size() * 2); + } + public: unsigned long TotalEvents; @@ -314,7 +327,7 @@ public: * required you must do this yourself. * @param eh The event handler object to remove */ - virtual void DelFd(EventHandler* eh) = 0; + virtual void DelFd(EventHandler* eh); /** Returns true if a file descriptor exists in * the socket engine's list. -- cgit v1.3.1-10-gc9f91