(svn r20510) -Codechange: unify packet queue handling and make insertion O(1) instead of O(n)
This commit is contained in:
@@ -74,6 +74,22 @@ enum TCPPacketType {
|
||||
/** Packet that wraps a command */
|
||||
struct CommandPacket;
|
||||
|
||||
/** A queue of CommandPackets. */
|
||||
class CommandQueue {
|
||||
CommandPacket *first; ///< The first packet in the queue.
|
||||
CommandPacket *last; ///< The last packet in the queue; only valid when first != NULL.
|
||||
|
||||
public:
|
||||
/** Initialise the command queue. */
|
||||
CommandQueue() : first(NULL), last(NULL) {}
|
||||
/** Clear the command queue. */
|
||||
~CommandQueue() { this->Free(); }
|
||||
void Append(CommandPacket *p);
|
||||
CommandPacket *Pop();
|
||||
CommandPacket *Peek();
|
||||
void Free();
|
||||
};
|
||||
|
||||
/** Status of a client */
|
||||
enum ClientStatus {
|
||||
STATUS_INACTIVE, ///< The client is not connected nor active
|
||||
@@ -106,7 +122,7 @@ public:
|
||||
|
||||
ClientStatus status; ///< Status of this client
|
||||
|
||||
CommandPacket *command_queue; ///< The command-queue awaiting delivery
|
||||
CommandQueue command_queue; ///< The command-queue awaiting delivery
|
||||
|
||||
NetworkRecvStatus CloseConnection(bool error = true);
|
||||
|
||||
|
Reference in New Issue
Block a user