초기커밋
This commit is contained in:
30
ServerCore/Pattern/Singleton.cs
Normal file
30
ServerCore/Pattern/Singleton.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
|
||||
namespace ServerCore;
|
||||
|
||||
//=============================================================================================
|
||||
// T 타입 객체를 단일 인스턴스로 생성해 주는 제네릭 클래스 이다.
|
||||
//
|
||||
// author : kangms
|
||||
//
|
||||
//=============================================================================================
|
||||
|
||||
public abstract class Singleton<T>
|
||||
where T : class, new()
|
||||
{
|
||||
// LazyThreadSafetyMode.ExecutionAndPublication : 멀티스레드 환경에서 처리시 안전하게 처리 한다 !!! (기본 설정)
|
||||
private static readonly Lazy<T> m_instance = new(() => new T());
|
||||
|
||||
public static T It => m_instance.Value;
|
||||
|
||||
public static string getName()
|
||||
{
|
||||
return nameof(T);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user