public bool TryGet(long key, out Match val) { try { RWL.AcquireReaderLock(500); return(Matches.TryGetValue(key, out val)); } finally { RWL.ReleaseReaderLock(); } }
public void Pop(long key) { try { RWL.AcquireReaderLock(1000); // this is already too long but who cares ? Matches.Remove(key); } finally { RWL.ReleaseReaderLock(); } }
public bool TryGet(string userName, out Presence pr) { try { RWL.AcquireReaderLock(500); pr = Values.FirstOrDefault(_pr => _pr.Value.User.UserName == userName).Value; return(pr != null); } finally { RWL.ReleaseReaderLock(); } }
public void Push(Match val) { try { RWL.AcquireReaderLock(1000); // this is already too long but who cares ? val.MatchId = Matches.Count; Matches.Add(val.MatchId, val); } finally { RWL.ReleaseReaderLock(); } }
public void Push(IPacket packet, Presence skip = null) { try { RWL.AcquireReaderLock(1000); // this is already too long but who cares ? foreach (var pr in Values.Where(pr => pr.Value != skip)) { pr.Value.Push(packet); } } finally { RWL.ReleaseReaderLock(); } }