| 164 | } |
| 165 | |
| 166 | Connection* ConnectionManager::GetConnectionByIndex(int i) |
| 167 | { |
| 168 | // Just to be consistent with allowing out of range values to be passed in here. |
| 169 | if (i < 0) |
| 170 | { |
| 171 | return NULL ; |
| 172 | } |
| 173 | |
| 174 | // Serialize thread access to the connections list |
| 175 | // which is shared with the listener socket/thread |
| 176 | soar_thread::Lock lock(&m_ConnectionsMutex) ; |
| 177 | |
| 178 | // Get the n'th connection |
| 179 | ConnectionsIter iter; |
| 180 | for (iter = m_Connections.begin() ; iter != m_Connections.end() && i > 0 ; iter++) |
| 181 | { |
| 182 | i-- ; |
| 183 | } |
| 184 | |
| 185 | if (iter == m_Connections.end()) |
| 186 | { |
| 187 | return NULL ; |
| 188 | } |
| 189 | |
| 190 | return *iter ; |
| 191 | } |
| 192 | |
| 193 | void ConnectionManager::RemoveConnection(Connection* pConnection) |
| 194 | { |
no test coverage detected