chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Res: [Chicken-users] Setting up hooks in garbage collection


From: Paulo Jabardo
Subject: Res: [Chicken-users] Setting up hooks in garbage collection
Date: Wed, 3 Jan 2007 13:17:45 +0100 (CET)

Thanks. I think that is the best solution.

Paulo Jabardo

----- Mensagem original ----
De: Zbigniew <address@hidden>
Para: Paulo Jabardo <address@hidden>
Cc: address@hidden
Enviadas: Terça-feira, 2 de Janeiro de 2007 21:24:22
Assunto: Re: [Chicken-users] Setting up hooks in garbage collection

I would think that your make-gsi-XXX could use set-finalizer! like so:

(set-finalizer! obj (lambda (x) (gsi-xxx-free x)))

It assumes you're willing to wait for a major GC and that  you are
sure this pointer is not being used anywhere else, although you would
have the latter issue with an explicit free.

If you're going to use finalizers very heavily, I would suggest you
call csi with -:d to activate debugging just so you can see how the
finalization is happening.

On 1/2/07, Paulo Jabardo <address@hidden> wrote:
> I'm beginning to develop a chicken interface to the GNU scientific library 
> (gsl). Several numerical procedures involve an operation such as:
>
> gsl_XXX *ptr = gsl_XXX_alloc(...)
>
> ...
>
> gsl_XXX_free(ptr)
>
>
> I would like to define a chicken variable that manages the pointer. But I 
> don't want to explicitely call the XXX_free function. Something like:
>
> (define resource (make-gsl-XXX ...))
>
> When the garbage collector collects resource, it would automatically call the 
> function gsl_XXX_free (or a chicken wrapper of it).
>
> Is that even possible?
> If it isn't could someone suggest a "schemish" approach to the problem?




__________________________________________________
Fale com seus amigos  de graça com o novo Yahoo! Messenger 
http://br.messenger.yahoo.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]