Version française
Home     About     Download     Resources     Contact us    
Browse thread
Preventing values from escaping a context
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Goswin von Brederlow <goswin-v-b@w...>
Subject: Re: [Caml-list] Preventing values from escaping a context
Rich Neswold <rich.neswold@gmail.com> writes:

> On Tue, Feb 9, 2010 at 12:45 PM, Tiphaine Turpin <Tiphaine.Turpin@irisa.fr>
> wrote:
>
>     Here is an adaptation of your example.
>
>
> Thank you! I'll experiment with your example to see if I can use it (like you
> said, it may be too complicated to add to the API.) Regardless, it was an
> interesting lesson and taught me a little more about the language.
>
> Thanks again,

Why not make the context a custom block with finalizer? The finalizer
then frees the resources. If the context escapes then it remains alive
and the finalizer will not be called any time soon. Only when it is no
longer reachable. That would also allow someone to create a context and
use it for a number of operations before forgeting it.

The drawback is that the finalizer will only be called when the GC runs
at some later time. If you need the resources to be freed right there
then it won't help.

MfG
        Goswin