Pol  Revision:4b29d2b
clienttransmit.h
Go to the documentation of this file.
1 #ifndef CLIENTSEND_H
2 #define CLIENTSEND_H
3 
4 #include <boost/noncopyable.hpp>
5 #include <memory>
6 #include <mutex>
7 #include <vector>
8 
9 #include "../../clib/message_queue.h"
10 #include "../../clib/rawtypes.h"
11 #include "../../clib/weakptr.h"
12 
13 namespace Pol
14 {
15 namespace Network
16 {
17 class Client;
18 
20 {
21  // store a weak_ptr as a guard for pkts after deleting
23  int len;
24  std::vector<u8> data;
26  bool remove;
27 
28  TransmitData() : client( 0 ), len( 0 ), disconnects( false ), remove( false ){};
29 };
30 
31 typedef std::unique_ptr<TransmitData> TransmitDataSPtr;
33 
34 class ClientTransmit : boost::noncopyable
35 {
36 public:
38  ~ClientTransmit();
39 
40  void AddToQueue( Client* client, const void* data, int len );
41  void QueueDisconnection( Client* client );
42  // queue delete and perform it in transmitthread, to be sure
43  // that the weak_ptr stays valid without PolLock
44  void QueueDelete( Client* client );
45  void Cancel();
46 
47  TransmitDataSPtr NextQueueEntry();
48 
49 private:
50  ClientTransmitQueue _transmitqueue;
51 };
52 
54 }
55 }
56 #endif
Clib::message_queue< TransmitDataSPtr > ClientTransmitQueue
void ClientTransmitThread()
std::unique_ptr< TransmitData > TransmitDataSPtr
ClientTransmitQueue _transmitqueue
weak_ptr< Client > client
std::vector< u8 > data
Definition: berror.cpp:12