Panda3D
 All Classes Functions Variables Enumerations
queuedReturn.h
1 // Filename: queuedReturn.h
2 // Created by: drose (25Feb00)
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 QUEUEDRETURN_H
16 #define QUEUEDRETURN_H
17 
18 #include "pandabase.h"
19 
20 #include "connectionListener.h"
21 #include "connection.h"
22 #include "netAddress.h"
23 #include "lightMutex.h"
24 #include "pdeque.h"
25 #include "config_net.h"
26 #include "lightMutexHolder.h"
27 
28 #include <algorithm>
29 
30 ////////////////////////////////////////////////////////////////////
31 // Class : QueuedReturn
32 // Description : This is the implementation of a family of things that
33 // queue up their return values for later retrieval by
34 // client code, like QueuedConnectionReader,
35 // QueuedConnectionListener, QueuedConnectionManager.
36 ////////////////////////////////////////////////////////////////////
37 template<class Thing>
38 class QueuedReturn {
39 PUBLISHED:
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  bool get_overflow_flag() const;
45  void reset_overflow_flag();
46 
47 protected:
48  QueuedReturn();
49  ~QueuedReturn();
50 
51  INLINE bool thing_available() const;
52  bool get_thing(Thing &thing);
53 
54  bool enqueue_thing(const Thing &thing);
55  bool enqueue_unique_thing(const Thing &thing);
56 
57 private:
58  LightMutex _mutex;
59  pdeque<Thing> _things;
60  bool _available;
61  int _max_queue_size;
62  bool _overflow_flag;
63 };
64 
65 #include "queuedReturn.I"
66 
67 #endif
68 
bool get_overflow_flag() const
Returns true if the queue has overflowed since the last call to reset_overflow_flag() (implying that ...
Definition: queuedReturn.I:70
int get_max_queue_size() const
Returns the maximum size the queue is allowed to grow to.
Definition: queuedReturn.I:43
void reset_overflow_flag()
Resets the overflow flag so that get_overflow_flag() will return false until a new overflow occurs...
Definition: queuedReturn.I:82
int get_current_queue_size() const
Returns the current number of things in the queue.
Definition: queuedReturn.I:54
void set_max_queue_size(int max_size)
Sets the maximum size the queue is allowed to grow to.
Definition: queuedReturn.I:30
This is the implementation of a family of things that queue up their return values for later retrieva...
Definition: queuedReturn.h:38
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition: lightMutex.h:45