From fce0beff8381f2eec8fe184daf192a453c303c73 Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Mon, 28 Dec 2020 12:40:12 +0100 Subject: [PATCH] Remove old eventfd on thread concept --- mainapp.cpp | 20 -------------------- threaddata.cpp | 24 ------------------------ threaddata.h | 7 ------- 3 files changed, 0 insertions(+), 51 deletions(-) diff --git a/mainapp.cpp b/mainapp.cpp index b21eaf5..e2f537a 100644 --- a/mainapp.cpp +++ b/mainapp.cpp @@ -16,21 +16,8 @@ void do_thread_work(ThreadData *threadData) std::vector packetQueueIn; - uint64_t eventfd_value = 0; - while (threadData->running) { - if (eventfd_value > 0) - { - for (Client_p client : threadData->getReadyForDequeueing()) - { - //client->queuedMessagesToBuffer(); - client->writeBufIntoFd(); - } - threadData->clearReadyForDequeueing(); - eventfd_value = 0; - } - int fdcount = epoll_wait(epoll_fd, events, MAX_EVENTS, 100); if (fdcount < 0) @@ -46,13 +33,6 @@ void do_thread_work(ThreadData *threadData) struct epoll_event cur_ev = events[i]; int fd = cur_ev.data.fd; - // If this thread was actively woken up. - if (fd == threadData->event_fd) - { - read(fd, &eventfd_value, sizeof(uint64_t)); - continue; - } - Client_p client = threadData->getClient(fd); if (client) diff --git a/threaddata.cpp b/threaddata.cpp index e5feab7..7ce0fb0 100644 --- a/threaddata.cpp +++ b/threaddata.cpp @@ -7,13 +7,6 @@ ThreadData::ThreadData(int threadnr, std::shared_ptr &subscri threadnr(threadnr) { epollfd = check(epoll_create(999)); - event_fd = eventfd(0, EFD_NONBLOCK); - - struct epoll_event ev; - memset(&ev, 0, sizeof (struct epoll_event)); - ev.data.fd = event_fd; - ev.events = EPOLLIN; - check(epoll_ctl(epollfd, EPOLL_CTL_ADD, event_fd, &ev)); } void ThreadData::moveThreadHere(std::thread &&thread) @@ -79,22 +72,5 @@ std::shared_ptr &ThreadData::getSubscriptionStore() return subscriptionStore; } -void ThreadData::wakeUpThread() -{ - uint64_t one = 1; - write(event_fd, &one, sizeof(uint64_t)); -} - -void ThreadData::addToReadyForDequeuing(Client_p &client) -{ - std::lock_guard lock(readForDequeuingMutex); - this->readyForDequeueing.insert(client); -} - -void ThreadData::clearReadyForDequeueing() -{ - std::lock_guard lock(readForDequeuingMutex); - this->readyForDequeueing.clear(); -} diff --git a/threaddata.h b/threaddata.h index 6ba3061..a894b0c 100644 --- a/threaddata.h +++ b/threaddata.h @@ -24,15 +24,12 @@ class ThreadData std::unordered_map clients_by_fd; std::mutex clients_by_fd_mutex; std::shared_ptr subscriptionStore; - std::unordered_set readyForDequeueing; - std::mutex readForDequeuingMutex; public: bool running = true; std::thread thread; int threadnr = 0; int epollfd = 0; - int event_fd = 0; ThreadData(int threadnr, std::shared_ptr &subscriptionStore); @@ -43,10 +40,6 @@ public: void removeClient(Client_p client); void removeClient(int fd); std::shared_ptr &getSubscriptionStore(); - void wakeUpThread(); - void addToReadyForDequeuing(Client_p &client); - std::unordered_set &getReadyForDequeueing() { return readyForDequeueing; } - void clearReadyForDequeueing(); }; #endif // THREADDATA_H -- libgit2 0.21.4