*/
#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()
mPoll.removeFD(mStopEvent.getFD());
}
-} // namespace utils
+EventPoll& ThreadPollDispatcher::getPoll()
+{
+ return mPoll;
+}
+
+} // namespace epoll
} // namespace vasum