Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

RecycleableDatabase

syadeu edited this page Apr 15, 2021 · 4 revisions

Namespace: Syadeu.Database

public abstract class RecycleableDatabase<T> : IRecycleable, IDisposable, IValidation where T : class

재사용 가능 데이터 객체입니다.

Inheritance: System.Object -> RecycleableDatabase
Derived: FMODSound
Implements: IRecycleable, IDisposable, IValidation

Overview

  • 데이터 기반 객체를 쉽게 풀링할 수 있습니다.

Remarks

Description

Examples

아래는 간단하게 데이터 객체를 정의하고, 해당 객체를 풀링하는 방법에 대해 설명합니다.

// 객체를 정의할때, 이 객체는 여러 코드에서 재사용이 될 객체가 됨으로,
// 생성자를 통해 초기값을 정의하는 것이 아닌,
// override OnInitialize를 통해 초기값을 정의하여야 합니다.
public sealed class TestClass : RecycleableDatabase<TestClass>
{
    /*
    	... Some Datas ...
    */
    protected override void OnInitialize()
    {
        /*
        	... Some Initialize Codes ...
        */
    }
}

public void TestPullingData()
{
    Debug.Log($"Instance Count: {TestClass.InstanceCount}");
    
    // 풀링할 인스턴스가 남아있으면 받아옵니다.
    // 이 예제에서는 이전에 아무 인스턴스도 만들지 않았으므로 null 를 반환합니다.
    TestClass _ins = TestClass.GetDatabase();
    if (_ins == null)
    {
        // new 키워드로 객체를 생성하면 자동으로 해당 객체의
        // 풀링 시스템에 편입됩니다.
        // 편입된 직후 객체는 Initialize를 호출합니다.
        _ins = new TestClass();
    }
    
    Debug.Log($"Instance Count: {TestClass.InstanceCount}");
    
    // 사용이 끝나면, 끝났음을 알리고 재사용 풀로 돌려보냅니다.
    _ins.Terminate();
}

Public Static Properties

Name Description
InstanceCount 이 객체 타입의 총 인스턴스 갯수를 반환합니다.
Instances 이 객체 타입의 인스턴스들을 반환합니다.

Properties

Name Description
DataIndex 인스턴스의 고유 인덱스입니다.
Activated 이 객체가 사용 중 인지 반환합니다.
Disposed 이 객체의 메모리가 방출될 예정인지 반환합니다.
Deprecated transform
Deprecated WaitForDeletion

Public Static Methods

Name Description
GetInstance
GetDatabase

Protected Static Methods

Name Description
IsMainThread 이 메소드가 실행된 스레드가 유니티 메인스레드인지 반환합니다.

Protected Methods

Name Description
OnInitialize 이 오브젝트가 재사용 풀에서 대기 중, 요청에 의해 다시 꺼내져왔을때 호출되는 함수입니다.
OnTerminate 이 오브젝트가 사용을 마치고, 재사용 풀로 되돌아 갈때 호출되는 함수입니다.

Public Methods

Name Description
Initialize 이 객체를 초기화합니다.
Terminate 이 오브젝트의 사용이 완료되었음을 알리는 함수입니다.
Dispose 이 객체를 메모리에서 방출합니다.
IsValid 이 객체가 유효한지 반환합니다.
- Interfaces
- Enums
- Attributes
- Abstract Classes
- Classes
- Structs
- Exceptions

- Syadeu.Presentation
- Syadeu.Collections
- Syadeu.Collections.Converters
- Syadeu.Collections.Proxy
- Syadeu.Presentation.Proxy
- Syadeu.Presentation.Internal
- Syadeu.Presentation.Entities
- Syadeu.Presentation.Attributes
- Syadeu.Presentation.Components
- Syadeu.Presentation.Actions
- Syadeu.Presentation.Render
  • CameraData
  • CameraFrustum
  • IntersectionType
  • RenderSystem
  • WorldCanvasSystem
- Syadeu.Presentation.Data
  • DataContainerSystem
  • DataObjectBase
  • EntityAnimationClipEventData
- Syadeu.Presentation.Events

Clone this wiki locally