eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Registry':

Home

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

Class: Registry


Inheritance:

   Object
   |
   +--Collection
      |
      +--Set
         |
         +--Dictionary
            |
            +--IdentityDictionary
               |
               +--WeakIdentityDictionary
                  |
                  +--Registry
                     |
                     +--CachingRegistry
                     |
                     +--HandleRegistry

Package:
stx:libbasic
Category:
Collections-Weak
Version:
rev: 1.80 date: 2023/11/26 14:11:55
user: cg
file: Registry.st directory: libbasic
module: stx stc-classLibrary: libbasic

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 acquire the copy of the original,
this can be redefined in individual classes for faster copying
(typically, not all internal state, but only some device handles are needed for
finalization). 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. Some classes return a specialized private-class instance,
which only holds on the handle and implements #finalize.)
Example uses are found in Form, Color, ExternalStream and Font

copyright

COPYRIGHT (c) 1993,2015 by Claus Gittinger 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.

Instance protocol:

accessing
o  contents
return the collection of registered objects

element disposal
o  clearDeadSlots
an element (one of my keys) died - clear slots for
disposed keys, set corresponding values (i.e. executors) to nil
and inform the executors.

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

o  update: anAspect with: aParameter from: changedObject
(comment from inherited method)
one of our keys died - clear out slots for disposed keys.

enumerating
o  detect: aBlock ifNone: exceptionValue
detect a key, for which aBlock answers true

o  do: aBlock
evaluate aBlock for each registered object

private
o  findKeyOrNil: key
Look for the key in the receiver.
If it is found, return the index,
otherwise the index of the first unused slot.
Grow the receiver, if key was not found, and no unused slots were present.

Warning: an empty slot MUST be filled by the sender - it is only to be sent
by at:put: / add: - like methods.

Redefined to not nil values of expired keys here.

o  findKeyOrNilOrDeletedEntry: key
Look for the key in the receiver.
If it is found, return the index,
otherwise the index of the first unused slot.
Grow the receiver, if key was not found, and no unused slots were present.

Redefined to not nil values of expired keys here.

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  unregisterAll
remove registration of all entries.

o  unregisterAllForWhich: aOneArgBlock
remove registration of all entries, for which the argument,
aOneArgBlock 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
remove registration of all handles, 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).



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sun, 24 Nov 2024 15:17:31 GMT