Use std::string for CommandContainer text instead of giant static buffer

Use move semantics for CommandContainer instance where feasible
This commit is contained in:
Jonathan G Rennison
2018-08-13 12:16:41 +01:00
parent 957cff34dc
commit 940314a3c7
10 changed files with 90 additions and 42 deletions

View File

@@ -18,6 +18,7 @@
#include "tcp.h"
#include "../network_type.h"
#include "../../core/pool_type.hpp"
#include <memory>
#ifdef ENABLE_NETWORK
@@ -135,13 +136,16 @@ class CommandQueue {
CommandPacket *last; ///< The last packet in the queue; only valid when first != NULL.
uint count; ///< The number of items in the queue.
void Append(CommandPacket *p, bool move);
public:
/** Initialise the command queue. */
CommandQueue() : first(NULL), last(NULL), count(0) {}
/** Clear the command queue. */
~CommandQueue() { this->Free(); }
void Append(CommandPacket *p);
CommandPacket *Pop(bool ignore_paused = false);
void Append(CommandPacket &p) { this->Append(&p, false); }
void Append(CommandPacket &&p) { this->Append(&p, true); }
std::unique_ptr<CommandPacket> Pop(bool ignore_paused = false);
CommandPacket *Peek(bool ignore_paused = false);
void Free();
/** Get the number of items in the queue. */