This repository has been archived on 2026-04-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Tortuga/server/network_queue.hpp
T
Kayne Ruse f01463bab3 Added and tested the network queue in the server
This is a reimplementation of the old network queue, but using a class.
This still uses a separate thread, so that packets can wait if there's any
lag. Really, thinking about it, I wonder how necessary this was.

On the upside, no singletons this time. Which means that you can have
several instances of UDPNetworkManager. That's unintentional, but good to
know.
2013-11-03 00:22:41 +11:00

36 lines
608 B
C++

#ifndef NETWORKQUEUE_HPP_
#define NETWORKQUEUE_HPP_
#include "udp_network_utility.hpp"
#include "network_packet.hpp"
#include "SDL/SDL_thread.h"
#include <deque>
class NetworkQueue {
public:
NetworkQueue() = default;
~NetworkQueue() = default;
void Init(UDPNetworkUtility*);
void Quit();
void Kill();
NetworkPacket Peek();
NetworkPacket Pop();
void Flush();
private:
friend int networkQueueThread(void*);
void ResetMembers();
bool running = false;
UDPNetworkUtility* netUtil = nullptr;
SDL_sem* lock = nullptr;
SDL_Thread* thread = nullptr;
std::deque<NetworkPacket> queue;
};
#endif