На самом деле, она и не заканчивалась, просто я вот вчера пошёл в магазин ну типа в пятёрочку тут есть у меня недалеко на углу улицы и короче вот я пошёл иду такой а мне навстречу сам илон макс правда я не шучу реально илон маз к идёт такой и я ему такой привет а он такой тоже здравствуйте я спрашиваю типа как там с теслой и спайс икс а он перебивает меня и говорит смотри сейчас будет фокус ну я такой ладно и он типа раз и взрывается нахуй пиздец я тогда умер кстати
52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
/*
|
|
* Worker.hpp
|
|
* Copyright (c) 2023 Cyclone Team. Licensed under GNU GPLv3-only terms.
|
|
*
|
|
*/
|
|
|
|
#ifndef LIBSTADIUM_WORKER_HPP
|
|
#define LIBSTADIUM_WORKER_HPP
|
|
|
|
|
|
|
|
#include <atomic>
|
|
#include <queue>
|
|
#include <unordered_map>
|
|
|
|
#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<EventType, void()> Handlers; // Map of handlers associated with packet types TODO: may be it can be more optimized with reloaded operators
|
|
static std::unordered_map<EventAsyncID, Event> ExpectedEvents; // Map of expected events and their async IDs
|
|
static std::atomic<EventAsyncID> LastAsyncID; // Increments every use of Expect()
|
|
|
|
static std::queue<Event> OutgoingEvents; // FIFO of outgoing events
|
|
static std::queue<Event> 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<char> GetOutgoingDataVec ();
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif |