eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Registry':

Home

everywhere
www.exept.de
for:
[back]

Class: Registry


Inheritance:

   Object
   |
   +--Registry
      |
      +--CachingRegistry
      |
      +--HandleRegistry

Package:
stx:libbasic
Category:
System-Support
Version:
rev: 1.60 date: 2005/12/12 10:01:51
user: cg
file: Registry.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

Description:


Registries provide an easy interface to using WeakArrays. 
A class, which wants to be informed of instance-death, can put a created object
into a registry. The registry will create an executor, which is a (shallow-)copy 
of the object, and watch out for death of the original object. When it dies, 
the executor will be sent a #finalize message.
The trick with the shallow copy is especially nice, you can think of it as
being the original object which died.

All objects, which keep external resources (such as fileDescriptors, fonts, 
colormap-entries etc.) should be registered, so that the underlying resource
can be freed when the object goes away.

Of course, you too can use it to do whatever you need to do in case of the
death of an object.

Registries use #executor to aquire the copy of the original,
this can be redefined in registered classes for faster copying 
(typically, not all internal state but only some device handles are needed for 
finalization). I if the to-be-registered object is large, this method may also
return a stub (placeHolder) object. (i.e. there is no need for the copy to be
of the same class as the original, as long as it implements #finalize and frees
the relevant OS resources ...)
Example uses are found in Form, Color, ExternalStream and Font


    


Related information:

    WeakArray
    WeakIdentityDictionary
    WeakIdentitySet
    Font
    Form
    Color
    Cursor
    ExternalStream

Instance protocol:

accessing
o  contents
return the collection of registered objects.
Warning: this returns a weak collection.

dispose handling
o  informDispose: someHandle
send a dispose message - this is sent to the executor,
since the original is already gone

o  update: something with: aParameter from: changedObject
an instance has been destroyed - look which one it was

enumerating
o  do: aBlock
evaluate aBlock for each registered object

private
o  repairTally

o  resize

o  unregister: anObject atIndex: index
strictly private

queries
o  isEmpty

registering objects
o  register: anObject
register anObject, so that a copy of it gets the disposed message
when anObject dies (some time in the future)

o  register: anObject as: aHandle
register anObject, so that I later receive informDispose: with aHandle
(some time in the future)

o  registerChange: anObject
a registered object has changed, create a new executor

o  unregister: anObject
remove registration of anObject, without telling the executor;
should be sent, if we are no more interested in destruction of
anObject (i.e. it no longer holds external resources).

o  unregisterAllForWhich: aBlock
remove registration of all entries, for which the argument block
evaluates to true.
should be sent, if we are no more interested in destruction of
a group of objects (i.e. it no longer holds external resources).

o  unregisterAllForWhichHandle: aBlock



ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 20:56:42 GMT