From abf55fe8ce5f19113433287b1e9e97c85c2d2ec5 Mon Sep 17 00:00:00 2001 From: Jaemin Ryu Date: Tue, 22 Aug 2017 14:51:53 +0900 Subject: [PATCH] Remove gmainloop support from Mainloop Change-Id: I8af6a3b5b0149c6af53f9b7c6b2b639a3aaa8496 Signed-off-by: Jaemin Ryu --- include/klay/mainloop.h | 2 +- include/klay/rmi/service.h | 2 +- src/mainloop.cpp | 32 +++----------------------------- src/rmi/service.cpp | 4 ++-- 4 files changed, 7 insertions(+), 33 deletions(-) diff --git a/include/klay/mainloop.h b/include/klay/mainloop.h index 4b55729..b06d66b 100644 --- a/include/klay/mainloop.h +++ b/include/klay/mainloop.h @@ -41,7 +41,7 @@ public: void addEventSource(const int fd, const Event events, Callback&& callback); void removeEventSource(const int fd); bool dispatch(const int timeout); - void run(bool useGMainloop = false); + void run(); void stop(); private: diff --git a/include/klay/rmi/service.h b/include/klay/rmi/service.h index a08492c..83b68be 100644 --- a/include/klay/rmi/service.h +++ b/include/klay/rmi/service.h @@ -153,7 +153,7 @@ public: Service(const Service&) = delete; Service& operator=(const Service&) = delete; - void start(bool useGMainloop = false); + void start(); void stop(); void setAuditTrail(const AuditTrail& trail); diff --git a/src/mainloop.cpp b/src/mainloop.cpp index aebecd7..aea2f69 100644 --- a/src/mainloop.cpp +++ b/src/mainloop.cpp @@ -31,17 +31,6 @@ namespace runtime { -namespace { - -gboolean GIOCallback(GIOChannel* channel, GIOCondition condition, void *data) -{ - Mainloop* mainloop = reinterpret_cast(data); - mainloop->dispatch(-1); - return TRUE; -} - -} // namespace - Mainloop::Mainloop() : pollFd(::epoll_create1(EPOLL_CLOEXEC)), stopped(false) @@ -147,27 +136,12 @@ void Mainloop::prepare() addEventSource(wakeupSignal.getFd(), EPOLLIN, wakeupMainloop); } -void Mainloop::run(bool useGMainloop) +void Mainloop::run() { prepare(); - if (useGMainloop) { - GIOChannel* channel; - channel = g_io_channel_unix_new(pollFd); - if (channel == NULL) { - std::cout << "GMAINLOOP CHANNEL ALLOC FAILED" << std::endl; - return; - } - g_io_add_watch(channel, (GIOCondition)(G_IO_IN|G_IO_HUP), GIOCallback, this); - g_io_channel_unref(channel); - - while (!stopped) { - g_main_iteration(TRUE); - } - } else { - while (!stopped) { - dispatch(-1); - } + while (!stopped) { + dispatch(-1); } } diff --git a/src/rmi/service.cpp b/src/rmi/service.cpp index 8f6e03b..c9da900 100644 --- a/src/rmi/service.cpp +++ b/src/rmi/service.cpp @@ -46,7 +46,7 @@ Service::~Service() { } -void Service::start(bool useGMainloop) +void Service::start() { Socket socket(Socket::create(address)); @@ -58,7 +58,7 @@ void Service::start(bool useGMainloop) EPOLLIN | EPOLLHUP | EPOLLRDHUP, accept); - mainloop.run(useGMainloop); + mainloop.run(); } void Service::stop() -- 2.34.1