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.10 date: 2021/03/09 09:40:10
user: cg
file: Singleton.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

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 against races during instance creation

copyright

COPYRIGHT (c) 2006 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

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

o  theOnlyInstance
must check again because of possible raise

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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 16:05:35 GMT