Esempio n. 1
0
        public void TestRandomAllocation()
        {
            int          repeatCount  = 10000;
            int          range        = 100;
            IList <int>  allocated    = new List <int>();
            IntAllocator intAllocator = new IntAllocator(0, range);
            Random       rand         = new Random();

            while (repeatCount-- > 0)
            {
                if (rand.Next(2) == 0)
                {
                    int a = intAllocator.Allocate();
                    if (a > -1)
                    {
                        Assert.False(allocated.Contains(a));
                        allocated.Add(a);
                    }
                }
                else if (allocated.Count > 0)
                {
                    int a = allocated[0];
                    intAllocator.Free(a);
                    allocated.RemoveAt(0);
                }
            }
        }
Esempio n. 2
0
 public void HandleSessionShutdown(object sender, ShutdownEventArgs reason)
 {
     lock (_sessionMap)
     {
         var session = (ISession)sender;
         _sessionMap.Remove(session.ChannelNumber);
         _ints.Free(session.ChannelNumber);
     }
 }
Esempio n. 3
0
 public void HandleSessionShutdown(ISession session, ShutdownEventArgs reason)
 {
     lock (m_sessionMap)
     {
         m_sessionMap.Remove(session.ChannelNumber);
         Ints.Free(session.ChannelNumber);
         CheckAutoClose();
     }
 }
 public void HandleSessionShutdown(object sender, ShutdownEventArgs reason)
 {
     lock (m_sessionMap)
     {
         var session = (ISession)sender;
         m_sessionMap.Remove(session.ChannelNumber);
         Ints.Free(session.ChannelNumber);
         CheckAutoClose();
     }
 }
Esempio n. 5
0
 public void HandleSessionShutdown(ISession session, ShutdownEventArgs reason)
 {
     //Console.WriteLine("SessionManager removing session "+session);
     lock (m_sessionMap)
     {
         m_sessionMap.Remove(session.ChannelNumber);
         Ints.Free(session.ChannelNumber);
         CheckAutoClose();
     }
 }
Esempio n. 6
0
 public Task HandleSessionShutdown(object sender, ShutdownEventArgs reason)
 {
     lock (m_sessionMap)
     {
         var session = (ISession)sender;
         m_sessionMap.Remove(session.ChannelNumber);
         Ints.Free(session.ChannelNumber);
         CheckAutoClose();
     }
     return(Task.CompletedTask);
 }