Terminating a process while finalizing

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

Terminating a process while finalizing

Mateusz Grotek
Hello,
I have a morph which forks a process.
What is the best way to terminate the process when my morph gets garbage
collected? I tried to use finalization, but for some reason it doesn't work.
Mateusz
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Terminating a process while finalizing

Levente Uzonyi-2
If the process has a strong reference to your morph (via self, a local
variable, etc), or any other object referencing your morph (e.g. the home
context of the block of the process), then the morph won't get garbage
collected while the process is running. If it only has a weak reference to
the morph, then it can check if the morph got garbage collected (the weak
reference became nil), and terminate normally.


Levente

On Wed, 11 Dec 2013, Mateusz Grotek wrote:

> Hello,
> I have a morph which forks a process.
> What is the best way to terminate the process when my morph gets garbage
> collected? I tried to use finalization, but for some reason it doesn't work.
> Mateusz
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: [SPAM] Re: [Newbies] Terminating a process while finalizing

Mateusz Grotek
Levente Uzonyi pisze:

> If the process has a strong reference to your morph (via self, a local
> variable, etc), or any other object referencing your morph (e.g. the
> home context of the block of the process), then the morph won't get
> garbage collected while the process is running. If it only has a weak
> reference to the morph, then it can check if the morph got garbage
> collected (the weak reference became nil), and terminate normally.
>
>
> Levente
>

Oh, so that's the reason the finalization didn't work. I suppose I need
to split the morph into two and keep a weak reference between them. Thanks!
Mateusz
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners