Panda3D
queuedConnectionManager.cxx
1 // Filename: queuedConnectionManager.cxx
2 // Created by: drose (09Feb00)
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 #include "queuedConnectionManager.h"
16 
17 #include <algorithm>
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: QueuedConnectionManager::Constructor
21 // Access: Public
22 // Description:
23 ////////////////////////////////////////////////////////////////////
24 QueuedConnectionManager::
25 QueuedConnectionManager() {
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: QueuedConnectionManager::Destructor
30 // Access: Public, Virtual
31 // Description:
32 ////////////////////////////////////////////////////////////////////
33 QueuedConnectionManager::
34 ~QueuedConnectionManager() {
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: QueuedConnectionManager::reset_connection_available
39 // Access: Public
40 // Description: Returns true if one of the readers/writers/listeners
41 // reported a connection reset recently. If so, the
42 // particular connection that has been reset can be
43 // extracted via get_reset_connection().
44 //
45 // Only connections which were externally reset are
46 // certain to appear in this list. Those which were
47 // explicitly closed via a call to close_connection()
48 // may or may not be reported. Furthermore, it is the
49 // responsibility of the caller to subsequently call
50 // close_connection() with any connection reported reset
51 // by this call. (There is no harm in calling
52 // close_connection() more than once on a given socket.)
53 ////////////////////////////////////////////////////////////////////
56  return thing_available();
57 }
58 
59 ////////////////////////////////////////////////////////////////////
60 // Function: QueuedConnectionManager::get_reset_connection
61 // Access: Public
62 // Description: If a previous call to reset_connection_available()
63 // returned true, this function will return information
64 // about the newly reset connection.
65 //
66 // Only connections which were externally reset are
67 // certain to appear in this list. Those which were
68 // explicitly closed via a call to close_connection()
69 // may or may not be reported. Furthermore, it is the
70 // responsibility of the caller to subsequently call
71 // close_connection() with any connection reported reset
72 // by this call. (There is no harm in calling
73 // close_connection() more than once on a given socket.)
74 //
75 // The return value is true if a connection was
76 // successfully returned, or false if there was, in
77 // fact, no reset connection. (This may happen if
78 // there are multiple threads accessing the
79 // QueuedConnectionManager).
80 ////////////////////////////////////////////////////////////////////
82 get_reset_connection(PT(Connection) &connection) {
83  return get_thing(connection);
84 }
85 
86 
87 ////////////////////////////////////////////////////////////////////
88 // Function: QueuedConnectionManager::connection_reset
89 // Access: Protected, Virtual
90 // Description: An internal function called by the ConnectionReader,
91 // ConnectionWriter, or ConnectionListener when a
92 // connection has been externally reset. This adds the
93 // connection to the queue of those which have recently
94 // been reset.
95 ////////////////////////////////////////////////////////////////////
96 void QueuedConnectionManager::
97 connection_reset(const PT(Connection) &connection, bool okflag) {
98  ConnectionManager::connection_reset(connection, okflag);
99 
100  // Largely, we don't care if this particular queue fills up. If it
101  // does, it probably just means the user isn't bothering to track
102  // this.
103  enqueue_unique_thing(connection);
104 }
bool get_reset_connection(PT(Connection) &connection)
If a previous call to reset_connection_available() returned true, this function will return informati...
bool reset_connection_available() const
Returns true if one of the readers/writers/listeners reported a connection reset recently.
Represents a single TCP or UDP socket for input or output.
Definition: connection.h:32