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