Last change
on this file since 173 was
173,
checked in by scheusso, 16 years ago
|
created classes PacketBuffer and ConnectionManager
PacketBuffer: (hopefully) threadsafe implementation of a packet buffer
for communication between threads
ConnectionManager: low-level managment of connection; implementation of
multiple threads
|
File size:
753 bytes
|
Rev | Line | |
---|
[173] | 1 | // |
---|
| 2 | // C++ Interface: PacketBuffer |
---|
| 3 | // |
---|
| 4 | // Description: |
---|
| 5 | // |
---|
| 6 | // |
---|
| 7 | // Author: Oliver Scheuss, (C) 2007 |
---|
| 8 | // |
---|
| 9 | // Copyright: See COPYING file that comes with this distribution |
---|
| 10 | // |
---|
| 11 | // |
---|
| 12 | |
---|
| 13 | #ifndef NETWORK_PACKETBUFFER_H |
---|
| 14 | #define NETWORK_PACKETBUFFER_H |
---|
| 15 | |
---|
| 16 | #include <queue> |
---|
| 17 | #include <string> |
---|
| 18 | |
---|
| 19 | namespace network{ |
---|
| 20 | |
---|
| 21 | struct PacketEnvelope{ |
---|
| 22 | int length; |
---|
| 23 | int data; |
---|
| 24 | }; |
---|
| 25 | |
---|
| 26 | struct QueueItem{ |
---|
| 27 | PacketEnvelope *packet; |
---|
| 28 | QueueItem *next; |
---|
| 29 | }; |
---|
| 30 | |
---|
| 31 | class PacketBuffer{ |
---|
| 32 | public: |
---|
| 33 | PacketBuffer(); |
---|
| 34 | bool isLocked(); |
---|
| 35 | bool isEmpty(); |
---|
| 36 | // pops a packet from the queue |
---|
| 37 | PacketEnvelope *pop(); |
---|
| 38 | // pushs a packet to the queue |
---|
| 39 | bool push(PacketEnvelope pck); |
---|
| 40 | void print(); |
---|
| 41 | private: |
---|
| 42 | bool locked; |
---|
| 43 | QueueItem *first; |
---|
| 44 | QueueItem *last; |
---|
| 45 | }; |
---|
| 46 | |
---|
| 47 | } //namespace |
---|
| 48 | #endif /* NETWORK_PACKETBUFFER_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.