예제 #1
0
        public bool TryGet(long key, out Match val)
        {
            try
            {
                RWL.AcquireReaderLock(500);

                return(Matches.TryGetValue(key, out val));
            }
            finally
            {
                RWL.ReleaseReaderLock();
            }
        }
예제 #2
0
        public void Pop(long key)
        {
            try
            {
                RWL.AcquireReaderLock(1000); // this is already too long but who cares ?

                Matches.Remove(key);
            }
            finally
            {
                RWL.ReleaseReaderLock();
            }
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        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();
            }
        }
예제 #5
0
        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();
            }
        }