Re[2]: [gclist] Finalization and object orientation.

stuart stuart@cosc.canterbury.ac.nz
Fri, 28 Mar 1997 15:26:13 +1200


> File handles seem to be the kind of resource that a finalizer 
> is handy for: they have no owner but the process, they are 
> easily encapsulated in a class, and it can be hard to know 
> statically when the last user of file is gone.  But they are 
> also hard to write a finalizer for: they can be a scarce 
> resource, the system doesn't know that when you run out you 
> should do a gc and finalize sweep, 

at some level it must be known that file handles are a 'scarce'
resource, so at some level you could do something like:

try {
   file = IO.openFile(fileName);
} catch (noFileHandlesLeft e) {
   Runtime.doGarbageCollection();
   Runtime.doFinalisation();
   file = IO.openFile(fileName);
}

i see no reason why this can't be done inside IO.openFile, thus
keeping the scope of the knowledge (that file handles are scarce)
within the package.

stuart


-- 
         stuart yeates <stuart@cosc.canterbury.ac.nz> aka `loam'
                  you are a child of the kernel space 
            no less than the daemons and the device drivers,
                   you have a right to execute here.



-- 
         stuart yeates <stuart@cosc.canterbury.ac.nz> aka `loam'
                  you are a child of the kernel space 
            no less than the daemons and the device drivers,
                   you have a right to execute here.