Loading src/connection.cpp +1 −14 Changes for src/connection.cpp: 1 added line, 14 removed lines. Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ size_t netplus::con::getRecvLength(){ void netplus::con::sending(bool state) { _sending = state; _pollapi->sendReady(this,state); _eventapi->sendReady(this,state); } bool netplus::con::issending() { Loading Loading @@ -262,18 +262,6 @@ int netplus::con::searchValue(con::condata* startblock, con::condata** findblock return -1; } netplus::con::con(pollapi *poll) { _ReadDataFirst=nullptr; _ReadDataLast=nullptr; _ReadDataLength=0; _SendDataFirst=nullptr; _SendDataLast=nullptr; _SendDataLength=0; _pollapi=poll; _sending=false; } netplus::con::con(){ _ReadDataFirst=nullptr; _ReadDataLast=nullptr; Loading @@ -281,7 +269,6 @@ netplus::con::con(){ _SendDataFirst=nullptr; _SendDataLast=nullptr; _SendDataLength=0; _pollapi=nullptr; _sending=false; } Loading src/connection.h +3 −3 Changes for src/connection.h: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ #pragma once namespace netplus { class pollapi; class eventapi; class con { public: Loading @@ -50,7 +50,7 @@ namespace netplus { friend class con; }; con(pollapi *event); con(eventapi *event); ~con(); /*Cache helper functions*/ Loading Loading @@ -102,7 +102,7 @@ namespace netplus { /*Outgoing Data*/ condata *_SendDataFirst; condata *_SendDataLast; pollapi *_pollapi; eventapi *_eventapi; /*if pollout*/ bool _sending; Loading src/eventapi.h +5 −29 Changes for src/eventapi.h: 5 added lines, 29 removed lines. Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ #pragma once namespace netplus { class pollapi; class eventapi { public: /*HTTP API Events*/ Loading @@ -42,40 +44,13 @@ namespace netplus { virtual void DisconnectEvent(con *curcon); /*memory allocation*/ virtual void CreateConnetion(con **curon,pollapi *pabi); virtual void deleteConnetion(con *curon); }; class pollapi { public: pollapi(eventapi *eapi){ _evtapi=eapi; }; virtual ~pollapi(){ }; enum EventHandlerStatus{EVIN=0,EVOUT=1,EVUP=2,EVERR=3,EVWAIT=4,EVCON=5}; virtual void initEventHandler()=0; virtual const char *getpolltype()=0; /*pollstate*/ virtual int pollState(int pos)=0; /*EventHandler*/ virtual unsigned int waitEventHandler()=0; virtual void ConnectEventHandler(int pos)=0; virtual void ReadEventHandler(int pos)=0; virtual void WriteEventHandler(int pos)=0; virtual void CloseEventHandler(int pos)=0; virtual void CreateConnetion(con **curon)=0; virtual void deleteConnetion(con *curon)=0; /*Connection Ready to send Data * DANGEROUS to burnout your cpu *only use this if know what you do!*/ virtual void sendReady(con *curcon,bool ready)=0; protected: eventapi *_evtapi; }; class event : public eventapi{ Loading @@ -83,6 +58,7 @@ namespace netplus { event(socket *serversocket); void runEventloop(); static void *WorkerThread(void *wrkevent); void sendReady(con *curcon,bool ready); virtual ~event(); static bool _Run; Loading src/linux/event.cpp +40 −17 Changes for src/linux/event.cpp: 40 added lines, 17 removed lines. Original line number Diff line number Diff line Loading @@ -63,6 +63,34 @@ __attribute__((__packed__)) ; namespace netplus { class pollapi { public: pollapi(eventapi *eapi){ _evtapi=eapi; }; virtual ~pollapi(){ }; enum EventHandlerStatus{EVIN=0,EVOUT=1,EVUP=2,EVERR=3,EVWAIT=4,EVCON=5}; virtual void initEventHandler()=0; virtual const char *getpolltype()=0; /*pollstate*/ virtual int pollState(int pos)=0; /*EventHandler*/ virtual unsigned int waitEventHandler()=0; virtual void ConnectEventHandler(int pos)=0; virtual void ReadEventHandler(int pos)=0; virtual void WriteEventHandler(int pos)=0; virtual void CloseEventHandler(int pos)=0; virtual void setpollEvents(con* curcon, int events)=0; protected: eventapi *_evtapi; }; class poll : public pollapi{ public: poll(socket* serversocket,eventapi *eapi) : pollapi(eapi){ Loading Loading @@ -161,7 +189,7 @@ namespace netplus { void ConnectEventHandler(int pos) { NetException exception; con *ccon; _evtapi->CreateConnetion(&ccon,this); _evtapi->CreateConnetion(&ccon); try { if(_ServerSocket->_Type==sockettype::TCP){ ccon->csock=std::make_shared<tcp>(); Loading Loading @@ -269,18 +297,7 @@ namespace netplus { } }; /*Connection Ready to send Data*/ void sendReady(con* curcon, bool ready) { if (ready) { _setpollEvents(curcon, EPOLLIN | EPOLLOUT); } else { _setpollEvents(curcon, EPOLLIN); } }; void _setpollEvents(con* curcon, int events) { void setpollEvents(con* curcon, int events) { NetException except; struct poll_event setevent { 0 }; setevent.events = events; Loading Loading @@ -392,14 +409,22 @@ namespace netplus { //dummy }; void eventapi::CreateConnetion(con **curcon,pollapi *pabi){ *curcon=new con(pabi); void eventapi::CreateConnetion(con **curcon){ *curcon=new con(this); }; void eventapi::deleteConnetion(con *curcon){ delete curcon; }; /*Connection Ready to send Data*/ void event::sendReady(con* curcon, bool ready) { if (ready) { _Poll->setpollEvents(curcon, EPOLLIN | EPOLLOUT); } else { _Poll->setpollEvents(curcon, EPOLLIN); } }; event::event(socket* serversocket) { if (!serversocket) { Loading @@ -407,11 +432,9 @@ namespace netplus { exp[NetException::Critical] << "server socket empty!"; throw exp; } _Poll = new poll(serversocket,this); } event::~event() { delete _Poll; } void event::runEventloop() { Loading Loading
src/connection.cpp +1 −14 Changes for src/connection.cpp: 1 added line, 14 removed lines. Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ size_t netplus::con::getRecvLength(){ void netplus::con::sending(bool state) { _sending = state; _pollapi->sendReady(this,state); _eventapi->sendReady(this,state); } bool netplus::con::issending() { Loading Loading @@ -262,18 +262,6 @@ int netplus::con::searchValue(con::condata* startblock, con::condata** findblock return -1; } netplus::con::con(pollapi *poll) { _ReadDataFirst=nullptr; _ReadDataLast=nullptr; _ReadDataLength=0; _SendDataFirst=nullptr; _SendDataLast=nullptr; _SendDataLength=0; _pollapi=poll; _sending=false; } netplus::con::con(){ _ReadDataFirst=nullptr; _ReadDataLast=nullptr; Loading @@ -281,7 +269,6 @@ netplus::con::con(){ _SendDataFirst=nullptr; _SendDataLast=nullptr; _SendDataLength=0; _pollapi=nullptr; _sending=false; } Loading
src/connection.h +3 −3 Changes for src/connection.h: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ #pragma once namespace netplus { class pollapi; class eventapi; class con { public: Loading @@ -50,7 +50,7 @@ namespace netplus { friend class con; }; con(pollapi *event); con(eventapi *event); ~con(); /*Cache helper functions*/ Loading Loading @@ -102,7 +102,7 @@ namespace netplus { /*Outgoing Data*/ condata *_SendDataFirst; condata *_SendDataLast; pollapi *_pollapi; eventapi *_eventapi; /*if pollout*/ bool _sending; Loading
src/eventapi.h +5 −29 Changes for src/eventapi.h: 5 added lines, 29 removed lines. Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ #pragma once namespace netplus { class pollapi; class eventapi { public: /*HTTP API Events*/ Loading @@ -42,40 +44,13 @@ namespace netplus { virtual void DisconnectEvent(con *curcon); /*memory allocation*/ virtual void CreateConnetion(con **curon,pollapi *pabi); virtual void deleteConnetion(con *curon); }; class pollapi { public: pollapi(eventapi *eapi){ _evtapi=eapi; }; virtual ~pollapi(){ }; enum EventHandlerStatus{EVIN=0,EVOUT=1,EVUP=2,EVERR=3,EVWAIT=4,EVCON=5}; virtual void initEventHandler()=0; virtual const char *getpolltype()=0; /*pollstate*/ virtual int pollState(int pos)=0; /*EventHandler*/ virtual unsigned int waitEventHandler()=0; virtual void ConnectEventHandler(int pos)=0; virtual void ReadEventHandler(int pos)=0; virtual void WriteEventHandler(int pos)=0; virtual void CloseEventHandler(int pos)=0; virtual void CreateConnetion(con **curon)=0; virtual void deleteConnetion(con *curon)=0; /*Connection Ready to send Data * DANGEROUS to burnout your cpu *only use this if know what you do!*/ virtual void sendReady(con *curcon,bool ready)=0; protected: eventapi *_evtapi; }; class event : public eventapi{ Loading @@ -83,6 +58,7 @@ namespace netplus { event(socket *serversocket); void runEventloop(); static void *WorkerThread(void *wrkevent); void sendReady(con *curcon,bool ready); virtual ~event(); static bool _Run; Loading
src/linux/event.cpp +40 −17 Changes for src/linux/event.cpp: 40 added lines, 17 removed lines. Original line number Diff line number Diff line Loading @@ -63,6 +63,34 @@ __attribute__((__packed__)) ; namespace netplus { class pollapi { public: pollapi(eventapi *eapi){ _evtapi=eapi; }; virtual ~pollapi(){ }; enum EventHandlerStatus{EVIN=0,EVOUT=1,EVUP=2,EVERR=3,EVWAIT=4,EVCON=5}; virtual void initEventHandler()=0; virtual const char *getpolltype()=0; /*pollstate*/ virtual int pollState(int pos)=0; /*EventHandler*/ virtual unsigned int waitEventHandler()=0; virtual void ConnectEventHandler(int pos)=0; virtual void ReadEventHandler(int pos)=0; virtual void WriteEventHandler(int pos)=0; virtual void CloseEventHandler(int pos)=0; virtual void setpollEvents(con* curcon, int events)=0; protected: eventapi *_evtapi; }; class poll : public pollapi{ public: poll(socket* serversocket,eventapi *eapi) : pollapi(eapi){ Loading Loading @@ -161,7 +189,7 @@ namespace netplus { void ConnectEventHandler(int pos) { NetException exception; con *ccon; _evtapi->CreateConnetion(&ccon,this); _evtapi->CreateConnetion(&ccon); try { if(_ServerSocket->_Type==sockettype::TCP){ ccon->csock=std::make_shared<tcp>(); Loading Loading @@ -269,18 +297,7 @@ namespace netplus { } }; /*Connection Ready to send Data*/ void sendReady(con* curcon, bool ready) { if (ready) { _setpollEvents(curcon, EPOLLIN | EPOLLOUT); } else { _setpollEvents(curcon, EPOLLIN); } }; void _setpollEvents(con* curcon, int events) { void setpollEvents(con* curcon, int events) { NetException except; struct poll_event setevent { 0 }; setevent.events = events; Loading Loading @@ -392,14 +409,22 @@ namespace netplus { //dummy }; void eventapi::CreateConnetion(con **curcon,pollapi *pabi){ *curcon=new con(pabi); void eventapi::CreateConnetion(con **curcon){ *curcon=new con(this); }; void eventapi::deleteConnetion(con *curcon){ delete curcon; }; /*Connection Ready to send Data*/ void event::sendReady(con* curcon, bool ready) { if (ready) { _Poll->setpollEvents(curcon, EPOLLIN | EPOLLOUT); } else { _Poll->setpollEvents(curcon, EPOLLIN); } }; event::event(socket* serversocket) { if (!serversocket) { Loading @@ -407,11 +432,9 @@ namespace netplus { exp[NetException::Critical] << "server socket empty!"; throw exp; } _Poll = new poll(serversocket,this); } event::~event() { delete _Poll; } void event::runEventloop() { Loading