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