ExternalSemaphoreTable curious garbageCollect

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ExternalSemaphoreTable curious garbageCollect

Ben Coman
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

Reply | Threaded
Open this post in threaded view
|

Re: ExternalSemaphoreTable curious garbageCollect

Henrik Sperre Johansen
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
Reply | Threaded
Open this post in threaded view
|

Re: ExternalSemaphoreTable curious garbageCollect

Ben Coman
On Thu, Sep 22, 2016 at 2:54 PM, Henrik Sperre Johansen
<[hidden email]> 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