using System;

namespace BingoBrain.Core
{



    public class Singleton<T> : ISingleton, IDisposable where T : Singleton<T>, new()
    {
        private static T mInstance;

        private static readonly object LockObject = new();

        public static T Instance
        {
            get
            {
                lock (LockObject)
                {
                    mInstance ??= new T();
                    mInstance.OnSingletonInit();
                }

                return mInstance;
            }
        }

        public virtual void Dispose()
        {
            mInstance = null;
        }

        public void OnSingletonInit()
        {
        }
    }
}