Panda3D
|
00001 // Filename: queuedConnectionManager.cxx 00002 // Created by: drose (09Feb00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "queuedConnectionManager.h" 00016 00017 #include <algorithm> 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: QueuedConnectionManager::Constructor 00021 // Access: Public 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 QueuedConnectionManager:: 00025 QueuedConnectionManager() { 00026 } 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: QueuedConnectionManager::Destructor 00030 // Access: Public, Virtual 00031 // Description: 00032 //////////////////////////////////////////////////////////////////// 00033 QueuedConnectionManager:: 00034 ~QueuedConnectionManager() { 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: QueuedConnectionManager::reset_connection_available 00039 // Access: Public 00040 // Description: Returns true if one of the readers/writers/listeners 00041 // reported a connection reset recently. If so, the 00042 // particular connection that has been reset can be 00043 // extracted via get_reset_connection(). 00044 // 00045 // Only connections which were externally reset are 00046 // certain to appear in this list. Those which were 00047 // explicitly closed via a call to close_connection() 00048 // may or may not be reported. Furthermore, it is the 00049 // responsibility of the caller to subsequently call 00050 // close_connection() with any connection reported reset 00051 // by this call. (There is no harm in calling 00052 // close_connection() more than once on a given socket.) 00053 //////////////////////////////////////////////////////////////////// 00054 bool QueuedConnectionManager:: 00055 reset_connection_available() const { 00056 return thing_available(); 00057 } 00058 00059 //////////////////////////////////////////////////////////////////// 00060 // Function: QueuedConnectionManager::get_reset_connection 00061 // Access: Public 00062 // Description: If a previous call to reset_connection_available() 00063 // returned true, this function will return information 00064 // about the newly reset connection. 00065 // 00066 // Only connections which were externally reset are 00067 // certain to appear in this list. Those which were 00068 // explicitly closed via a call to close_connection() 00069 // may or may not be reported. Furthermore, it is the 00070 // responsibility of the caller to subsequently call 00071 // close_connection() with any connection reported reset 00072 // by this call. (There is no harm in calling 00073 // close_connection() more than once on a given socket.) 00074 // 00075 // The return value is true if a connection was 00076 // successfully returned, or false if there was, in 00077 // fact, no reset connection. (This may happen if 00078 // there are multiple threads accessing the 00079 // QueuedConnectionManager). 00080 //////////////////////////////////////////////////////////////////// 00081 bool QueuedConnectionManager:: 00082 get_reset_connection(PT(Connection) &connection) { 00083 return get_thing(connection); 00084 } 00085 00086 00087 //////////////////////////////////////////////////////////////////// 00088 // Function: QueuedConnectionManager::connection_reset 00089 // Access: Protected, Virtual 00090 // Description: An internal function called by the ConnectionReader, 00091 // ConnectionWriter, or ConnectionListener when a 00092 // connection has been externally reset. This adds the 00093 // connection to the queue of those which have recently 00094 // been reset. 00095 //////////////////////////////////////////////////////////////////// 00096 void QueuedConnectionManager:: 00097 connection_reset(const PT(Connection) &connection, bool okflag) { 00098 ConnectionManager::connection_reset(connection, okflag); 00099 00100 // Largely, we don't care if this particular queue fills up. If it 00101 // does, it probably just means the user isn't bothering to track 00102 // this. 00103 enqueue_unique_thing(connection); 00104 }