/* * Worker.hpp * Copyright (c) 2023 Cyclone Team. Licensed under GNU GPLv3-only terms. * */ #ifndef LIBSTADIUM_WORKER_HPP #define LIBSTADIUM_WORKER_HPP #include #include #include #include "KLDR.hpp" #include "Event.hpp" namespace Stadium::v1 { // Working class class Worker { private: static bool Running; // If workers are running static std::unordered_map Handlers; // Map of handlers associated with packet types TODO: may be it can be more optimized with reloaded operators static std::unordered_map ExpectedEvents; // Map of expected events and their async IDs static std::atomic LastAsyncID; // Increments every use of Expect() static std::queue OutgoingEvents; // FIFO of outgoing events static std::queue IngoingEvents; // FIFO of ingoing events public: Event ParseRawData (const char*); void PutIngoing (const char*); void PutOutgoing (EventType, KLDRArray<>); void BindHandler (EventType, void()); void IngoingLoop (); std::vector GetOutgoingDataVec (); }; } #endif