Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/network/PacketBuffer.h @ 174

Last change on this file since 174 was 174, checked in by scheusso, 16 years ago

added boost:mutex to PacketBuffer in order to make it thread safe; adjuster PacketBufferTest

File size: 1.0 KB
Line 
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#include <boost/bind.hpp>
19#include <boost/thread/mutex.hpp>
20#include <boost/thread/mutex.hpp>
21
22//this is needed in order to make the packetbuffer threadsafe
23boost::mutex networkPacketBufferMutex;
24
25namespace network{
26
27struct PacketEnvelope{
28  int length;
29  int data;
30};
31
32struct QueueItem{
33  PacketEnvelope *packet;
34  QueueItem *next;
35};
36
37class PacketBuffer{
38public:
39  PacketBuffer();
40  bool isEmpty();
41  bool isClosed();
42  void setClosed(bool value);
43  void print();
44  // pops a packet from the queue
45  PacketEnvelope pop();
46  // pushs a packet to the queue
47  bool push(PacketEnvelope pck);
48private:
49  QueueItem *first;
50  QueueItem *last;
51  bool closed;
52 
53  //make it threadsafe
54//   boost::mutex mutex;
55};
56
57} //namespace
58#endif /* NETWORK_PACKETBUFFER_H */
Note: See TracBrowser for help on using the repository browser.