eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Singleton':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Singleton


Inheritance:

   Object
   |
   +--Singleton
      |
      +--Dolphin::DeafObject

Package:
stx:libbasic2
Category:
System-Support
Version:
rev: 1.7 date: 2019/04/03 06:37:30
user: stefan
file: Singleton.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Stefan Vogel (stefan@zwerg)

Description:


Subclasses of Singleton have only a single instance.
The instance creation methods ensure that there is only one instance.

Singletons that would have inherited from Object could inherit from
Singleton. For Singletons that do not inherit from Object, 
you have to copy the Singleton's code to your class.


[class instance variables:]
    theOnlyInstance     Object          The only instance of this class

[class variables:]
    Lock                RecursionLock   A global lock to protect agains races during instance creation


Class protocol:

accessing
o  singletonLock
can be used by other classes that are not subclasses of Singleton

o  theOnlyInstance

initialization
o  initialize
(comment from inherited method)
called only once - initialize signals

instance creation
o  basicNew
allocate a singleton in a thread-safe way.
Do lazy locking here

o  basicNew: anInteger
allocate a singleton in a thread-safe way.
Do lazy locking here

o  new
allocate a singleton in a thread-safe way.
Do lazy locking here

o  new: count
allocate a singleton in a thread-safe way.
Do lazy locking here

o  releaseInstance
release the singleton's instance.
Use only for debugging!



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 18 Aug 2022 13:06:24 GMT