chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Calling out to C causing hang


From: Felix Winkelmann
Subject: Re: [Chicken-users] Calling out to C causing hang
Date: Mon, 07 Apr 2003 15:10:25 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.0) Gecko/20020530

Chris Double wrote:
On Tue, 08 Apr 2003 00:49, you wrote:

BTW, your call-out to C does not perform callbacks, right?


Yes it does. Here's the code I'm calling from Scheme.

void do_event(Display* display)
{
  XEvent event;
  int i = C_interrupts_enabled;
  /* C_interrupts_enabled = 0; */
  if(XPending(display))
        {
          XNextEvent(display, &event);
          /* call_handle_event is a Scheme function. If an interrupt occurs
while in there the programs hangs due to constantly performing a minor gc */
          call_handle_event(get_base_window(event.xany.window), event.type);
} /* C_interrupts_enabled = i; */
}

The call_handle_event is a scheme function:

(define-external (call_handle_event (c-pointer w) (unsigned-long type)) void ...)

If I wrap the function in the C_interrupts_enabled/disabled (ie. uncomment the relevant lines above) things seem to work fine. This is because handle_interrupts never gets called I assume.
From your question I'm guessing that there might be a problem with calling
back to scheme?


Not exactly a problem, but you have to make ABSOLUTELY SURE
that the do_event() (in your example) is a `foreign-callback-lambda[*]'.
That's essential! `foreign-lambda*' is wrong.

In the callback-situation, the old continuation has to be stored globally.


cheers,
felix





reply via email to

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