namespace Fort23.Core
{
    public class ClockPool
    {
        private static BetterList<Clock> clockPool = new BetterList<Clock>();

        public static Clock GetClock()
        {
            lock (clockPool)
            {
                if (clockPool.size > 0)
                {
                    Clock clock=  clockPool[0];
                    clock.isBreak = false;
                    clock.isLoadEnd = false;
                    clockPool.Remove(clock);
                    return clock;
                }

                Clock newClock = new Clock();
                return newClock;
            }
          
        }

        public static void EnterPool(Clock clock)
        {
            lock (clockPool)
            {
                if (!clockPool.Contains(clock))
                {
                    clockPool.Add(clock);
                }
            }
        }
    }
}