From 5859971a7e9ea814b0d0732579c329f3d808b931 Mon Sep 17 00:00:00 2001 From: lidgren Date: Sat, 26 May 2012 08:53:54 +0000 Subject: [PATCH] Expanded comment on TryGetValues thread safety in GetConnection --- Lidgren.Network/NetPeer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lidgren.Network/NetPeer.cs b/Lidgren.Network/NetPeer.cs index 26d78f3..14441b5 100644 --- a/Lidgren.Network/NetPeer.cs +++ b/Lidgren.Network/NetPeer.cs @@ -150,7 +150,11 @@ namespace Lidgren.Network public NetConnection GetConnection(IPEndPoint ep) { NetConnection retval; - m_connectionLookup.TryGetValue(ep, out retval); // this should not pose a threading problem, afaict + + // this should not pose a threading problem, m_connectionLookup is never added to concurrently + // and TryGetValue will not throw an exception on fail, only yield null, which is acceptable + m_connectionLookup.TryGetValue(ep, out retval); + return retval; }