Epoll refactor
[platform/core/security/vasum.git] / common / epoll / thread-poll-dispatcher.cpp
similarity index 73%
rename from common/utils/thread-poll-dispatcher.cpp
rename to common/epoll/thread-poll-dispatcher.cpp
index f350587..797a8c4 100644 (file)
  */
 
 #include "config.hpp"
-#include "utils/thread-poll-dispatcher.hpp"
-
-#include <sys/epoll.h>
+#include "epoll/thread-poll-dispatcher.hpp"
 
 namespace vasum {
-namespace utils {
+namespace epoll {
 
-ThreadPollDispatcher::ThreadPollDispatcher(EventPoll& poll)
-    : mPoll(poll)
-    , mThread([&]{ poll.dispatchLoop(); })
+ThreadPollDispatcher::ThreadPollDispatcher()
 {
-    auto controlCallback = [this](int, EventPoll::Events) -> bool {
+    auto controlCallback = [this](int, Events) -> bool {
         mStopEvent.receive();
         return false; // break the loop
     };
 
-    poll.addFD(mStopEvent.getFD(), EPOLLIN, std::move(controlCallback));
+    mPoll.addFD(mStopEvent.getFD(), EPOLLIN, std::move(controlCallback));
+    mThread = std::thread([this] {
+        mPoll.dispatchLoop();
+    });
 }
 
 ThreadPollDispatcher::~ThreadPollDispatcher()
@@ -49,5 +48,10 @@ ThreadPollDispatcher::~ThreadPollDispatcher()
     mPoll.removeFD(mStopEvent.getFD());
 }
 
-} // namespace utils
+EventPoll& ThreadPollDispatcher::getPoll()
+{
+    return mPoll;
+}
+
+} // namespace epoll
 } // namespace vasum