Panda3D
 All Classes Functions Variables Enumerations
datagramQueue.h
1 // Filename: datagramQueue.h
2 // Created by: drose (07Feb00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef DATAGRAMQUEUE_H
16 #define DATAGRAMQUEUE_H
17 
18 #include "pandabase.h"
19 
20 #include "netDatagram.h"
21 #include "pmutex.h"
22 #include "conditionVarFull.h"
23 #include "pdeque.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : DatagramQueue
27 // Description : A thread-safe, FIFO queue of NetDatagrams. This is used
28 // by ConnectionWriter for queuing up datagrams for
29 // its various threads to write to sockets.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_NET DatagramQueue {
32 public:
33  DatagramQueue();
34  ~DatagramQueue();
35  void shutdown();
36 
37  bool insert(const NetDatagram &data, bool block = false);
38  bool extract(NetDatagram &result);
39 
40  void set_max_queue_size(int max_size);
41  int get_max_queue_size() const;
42  int get_current_queue_size() const;
43 
44 private:
45  Mutex _cvlock;
46  ConditionVarFull _cv; // signaled when queue contents change.
47 
49  QueueType _queue;
50  bool _shutdown;
51  int _max_queue_size;
52 };
53 
54 #endif
55 
A specific kind of Datagram, especially for sending across or receiving from a network.
Definition: netDatagram.h:43
A standard mutex, or mutual exclusion lock.
Definition: pmutex.h:44
This class implements a condition variable; see ConditionVar for a brief introduction to this class...
A thread-safe, FIFO queue of NetDatagrams.
Definition: datagramQueue.h:31