[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Safely holding on to a <procedure> reference in C
From: |
Peter Bex |
Subject: |
Re: [Chicken-users] Safely holding on to a <procedure> reference in C |
Date: |
Mon, 21 Feb 2011 09:19:54 +0100 |
User-agent: |
Mutt/1.4.2.3i |
On Sun, Feb 20, 2011 at 08:55:24PM -0800, Naitik Shah wrote:
> Hi,
>
> I'm experimenting with Chicken and libevent using the bind extension to
> build a event based webserver. I'm trying to figure out if there's a way to
> have C code hold on to a <procedure> in a GC safe manner. The implementation
> I have so far works for a few requests, but eventually fails. Based on what
> I've learned so far it seems like this is because the GC is either throwing
> away or moving the <procedure> making the pointer in C being held by
> libevent invalid. Is it possible to hold on to a <procedure> like this?
I think you can use object-evict for that. It's from unit lolevel, see
http://wiki.call-cc.org/man/4/Unit%20lolevel#object-evict
Alternatively, you can construct a new GC root with CHICKEN_new_gc_root()
and put the procedure object in it with CHICKEN_gc_root_set():
http://wiki.call-cc.org/man/4/Embedding#chicken_new_gc_root
I don't think there's a Scheme interface for that, though.
Cheers,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
Re: [Chicken-users] Safely holding on to a <procedure> reference in C, Felix, 2011/02/22