TSingleton Record

Provides a simple implementation of the Singleton Pattern. Use this portal to get the shared instance of a certain class which must have a default constructor.

It also keeps track of the lifetime of the instances and will free them in reversed order.

Namespace: Spring.DesignPatterns
type
 TSingleton = record
 end;

The TSingleton type exposes the following members.

Show:
 NameDescription
Create@

Represents the static constructor of the TSingleton class.

Destroy@

Represents the static destructor of the TSingleton class.

Top
Show:
 NameDescription
GetInstance<T>

Gets the shared instance of a class.

Top
Show:
 NameDescription
fCriticalSection

Represents field fCriticalSection.

Top

This class just demonstrates how to apply the classical Singleton Pattern. It's recommended to use the Spring IoC container which is more flexible.

Public static members of this type are thread safe.