ExternalSemaphoreTable curious garbageCollect
A curiosity I can't work out and maybe I can learn something... ExternalSemaphoreTable unprotectedExternalObjects class ==> Array so in #freedSlotsIn:ratherThanIncreaseSizeTo: how does the garbageCollect manage to free slots given that the Array holds strongly to its elements? cheers -ben
The semaphores are strongly held, but not the objects that put them there. Sockets are the main users of the table. Sockets are finalized by removing registered semaphores from the table. Garbage collect triggers finalization. Hence, garbage collect can result in slots being freed. Cheers, Henry -- View this message in context: http://forum.world.st/ExternalSemaphoreTable-curious-garbageCollect-tp491654... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
On Thu, Sep 22, 2016 at 2:54 PM, Henrik Sperre Johansen <henrik.s.johansen@veloxit.no> wrote:
The semaphores are strongly held, but not the objects that put them there. Sockets are the main users of the table. Sockets are finalized by removing registered semaphores from the table. Garbage collect triggers finalization.
Hence, garbage collect can result in slots being freed.
Gotcha.Thanks for that insight. Socket>>finalize self primSocketDestroyGently: socketHandle. Smalltalk unregisterExternalObject: semaphore. Smalltalk unregisterExternalObject: readSemaphore. Smalltalk unregisterExternalObject: writeSemaphore. cheers -ben
participants (2)
-
Ben Coman -
Henrik Sperre Johansen