#ifndef THREADDATA_H #define THREADDATA_H #include #include #include #include #include #include #include #include #include #include "forward_declarations.h" #include "client.h" #include "subscriptionstore.h" #include "utils.h" #include "configfileparser.h" #include "authplugin.h" #include "logger.h" typedef void (*thread_f)(ThreadData *); class ThreadData { std::unordered_map clients_by_fd; std::mutex clients_by_fd_mutex; std::shared_ptr subscriptionStore; Logger *logger; void reload(std::shared_ptr settings); void wakeUpThread(); void doKeepAliveCheck(); public: Settings settingsLocalCopy; // Is updated on reload, within the thread loop. AuthPlugin authPlugin; bool running = true; std::thread thread; int threadnr = 0; int epollfd = 0; int taskEventFd = 0; std::mutex taskQueueMutex; std::forward_list> taskQueue; ThreadData(int threadnr, std::shared_ptr &subscriptionStore, std::shared_ptr settings); ThreadData(const ThreadData &other) = delete; ThreadData(ThreadData &&other) = delete; void start(thread_f f); void quit(); void giveClient(Client_p client); Client_p getClient(int fd); void removeClient(Client_p client); void removeClient(int fd); std::shared_ptr &getSubscriptionStore(); void initAuthPlugin(); void queueReload(std::shared_ptr settings); void queueDoKeepAliveCheck(); }; #endif // THREADDATA_H