public void TestNextObject2()
        {
            TimerManager timerManager = new TimerManager();

            ObjectsPool <PoolDummy> pool = new ObjectsPool <PoolDummy>(timerManager);
            PoolDummy o1 = pool.NextObject();
            PoolDummy o2 = pool.NextObject();
            PoolDummy o3 = pool.NextObject();

            Assert.AreEqual(pool.size, 0);

            pool.RecycleObject(o1);
            pool.RecycleObject(o2);
            Assert.AreEqual(pool.size, 2);

            PoolDummy o4 = pool.NextObject();
            PoolDummy o5 = pool.NextObject();
            PoolDummy o6 = pool.NextObject();

            Assert.AreEqual(pool.size, 0);

            Assert.AreEqual(o1, o4);
            Assert.AreEqual(o2, o5);
            Assert.AreNotEqual(o3, o6);
        }
Ejemplo n.º 2
0
        public void PostImmediately(Object sender, String name, Object data = null, Object data2 = null, Object data3 = null, Object data4 = null)
        {
            NotificationDelegateList list = FindList(name);

            if (list != null && list.Count() > 0)
            {
                Notification notification = m_notificatoinsPool.NextObject();
                notification.Init(sender, name, data, data2, data3, data4);

                list.NotifyDelegates(notification);

                m_notificatoinsPool.RecycleObject(notification);
            }
        }