On Tue, Apr 07, 2015 at 06:18:13PM +0200, Roland Plüss wrote:

> I'm using a similar trick in my own scripting language. Hoped I can get
> away in Smalltalk without it. It's certainly a working solution albeit
> not the most good one. Should do the trick for the time being.

Okay, what else do you think the VM can do? E.g. if I would
implement a "shutdown" command I would suspend all processes,
then run the global collection, then look at gcArray iterate
over them to call mourn.

"Stop the normal handling"
proc := (Process allInstances select: [:each |
                each name = 'finalization listener']) first suspend

"Check if other finalizers run or wait..This runs the risk if
new garbage is produced.. the vm will be upset and aborts.."
[(Process allInstances select: [:each | each name = 'finalization worker']) 
isEmpty]
        whileFalse: [Processor yield]


"Run GC which will signal finalization.."
ObjectMemory globalGarbageCollect

"Take the to be finalized array and mourn"
garbage := Processor instVarNamed: #gcArray
garbage ifNotNil: [garbage do: [:each | each mourn]]


Specially step 1 and 2 is a bit dangerous. You should suspend
other processes/work too to prevent from more GC to be produced.

_______________________________________________
help-smalltalk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to