eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'CachingRegistry':

Home

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

Class: CachingRegistry


Inheritance:

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

Package:
stx:libbasic
Category:
System-Support
Version:
rev: 1.12 date: 2021/01/20 11:02:59
user: cg
file: CachingRegistry.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


A CachingRegistry behaves generally like a registry;
However, it keeps hard references to the last n registered objects,
preventing them from being garbage collected (and finalized).
This is useful for resources, which do not cost too much memory,
but are expensive to allocate - a special candidate of this kind are
XFonts. With a CachingRegistry, fonts are kept a bit longer alive
and can therefore often be reused - even if temporarily unreferenced.

This is kind of experimental.



[instance variables:]
    keptObjects             Collection      hard referenced objects
    cacheSize               Integer         number of hard references

copyright

COPYRIGHT (c) 1999 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:

instance creation
o  new: cacheSize
(comment from inherited method)
return a new empty Set with space for anInteger elements


Instance protocol:

enumerating
o  detect: aBlock ifNone: exceptionValue
... additionaly move it to the front of the LRU chain

private
o  cacheSize: aNumber

registering objects
o  register: anObject as: aHandle
(comment from inherited method)
register anObject, so that I later receive informDispose: with aHandle
(some time in the future)

o  removeKey: anObject ifAbsent: absentBlock
(comment from inherited method)
remove the association under aKey from the collection,
return the value previously stored there.
If it was not in the collection return the result
from evaluating aBlock.

Redefined to avoid synchronization problems, in case
of interrupts (otherwise, there could be some other operation
on the receiver done by another process, which garbles my contents).

o  safeRemoveKey: anObject
(comment from inherited method)
redefined to block interrupts
(avoid change of the dictionary while accessing)



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Tue, 22 Oct 2024 14:26:44 GMT