From 612384b3d46d06eea6fd71ee6dc60471d0f9e3d1 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sun, 12 Apr 2015 16:20:13 +0200 Subject: Dispatch EventHandler events to dedicated virtual functions Remove enum EventType --- src/threadengines/threadengine_pthread.cpp | 50 +++++++++++++++++------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'src/threadengines') diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp index fcb4db444..6456d6df5 100644 --- a/src/threadengines/threadengine_pthread.cpp +++ b/src/threadengines/threadengine_pthread.cpp @@ -72,18 +72,21 @@ class ThreadSignalSocket : public EventHandler eventfd_write(fd, 1); } - void HandleEvent(EventType et, int errornum) + void OnEventHandlerRead() CXX11_OVERRIDE { - if (et == EVENT_READ) - { - eventfd_t dummy; - eventfd_read(fd, &dummy); - parent->OnNotify(); - } - else - { - ServerInstance->GlobalCulls.AddItem(this); - } + eventfd_t dummy; + eventfd_read(fd, &dummy); + parent->OnNotify(); + } + + void OnEventHandlerWrite() CXX11_OVERRIDE + { + ServerInstance->GlobalCulls.AddItem(this); + } + + void OnEventHandlerError(int errcode) CXX11_OVERRIDE + { + ThreadSignalSocket::OnEventHandlerWrite(); } }; @@ -122,18 +125,21 @@ class ThreadSignalSocket : public EventHandler write(send_fd, &dummy, 1); } - void HandleEvent(EventType et, int errornum) + void OnEventHandlerRead() CXX11_OVERRIDE + { + char dummy[128]; + read(fd, dummy, 128); + parent->OnNotify(); + } + + void OnEventHandlerWrite() CXX11_OVERRIDE + { + ServerInstance->GlobalCulls.AddItem(this); + } + + void OnEventHandlerError(int errcode) CXX11_OVERRIDE { - if (et == EVENT_READ) - { - char dummy[128]; - read(fd, dummy, 128); - parent->OnNotify(); - } - else - { - ServerInstance->GlobalCulls.AddItem(this); - } + ThreadSignalSocket::OnEventHandlerWrite(); } }; -- cgit v1.2.3