summaryrefslogtreecommitdiff
path: root/include/socketengine.h
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-01-23 19:17:22 -0500
committerAttila Molnar <attilamolnar@hush.com>2014-02-04 22:39:12 +0100
commit3752b3f59d5216d7dc6221a361efc76b9ad2273d (patch)
tree540ec25c9c643f1739875aa0add1f8a87a334e3c /include/socketengine.h
parentd7164e521b2bf961dab531dff3914a17dec88949 (diff)
New socketengine stuff:
Use vectors that grow as necessary instead of mass allocating everything at once Rework poll engine logic to make sense
Diffstat (limited to 'include/socketengine.h')
-rw-r--r--include/socketengine.h21
1 files changed, 17 insertions, 4 deletions
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<EventHandler*> 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<int> 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 <typename T>
+ void ResizeDouble(std::vector<T>& 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.