1 // Copyright 2009 The Archiveopteryx Developers <info@aox.org> 2 3 #ifndef EVENTLOOP_H 4 #define EVENTLOOP_H 5 6 #include "list.h" 7 8 9 class Connection; 10 11 12 class EventLoop 13 : public Garbage 14 { 15 public: 16 EventLoop(); 17 virtual ~EventLoop(); 18 19 virtual void start(); 20 virtual void stop( uint = 0 ); 21 virtual void addConnection( Connection * ); 22 virtual void removeConnection( Connection * ); 23 void closeAllExcept( Connection *, Connection * ); 24 void closeAllExceptListeners(); 25 void flushAll(); 26 27 void dispatch( Connection *, bool, bool, uint ); 28 29 bool inStartup() const; 30 void setStartup( bool ); 31 32 bool inShutdown() const; 33 34 List< Connection > *connections() const; 35 36 static void setup( EventLoop * = 0 ); 37 static EventLoop * global(); 38 static void shutdown(); 39 static void freeMemorySoon(); 40 41 virtual void addTimer( class Timer * ); 42 virtual void removeTimer( class Timer * ); 43 44 void setConnectionCounts(); 45 46 void shutdownSSL(); 47 48 void setMemoryUsage( uint ); 49 uint memoryUsage() const; 50 51 virtual void freeMemory(); 52 53 private: 54 class LoopData *d; 55 }; 56 57 58 #endif 59