[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MIT-Scheme-devel] callbacks
From: |
Matt Birkholz |
Subject: |
[MIT-Scheme-devel] callbacks |
Date: |
Wed, 23 Mar 2005 16:16:38 +0000 |
> From: Matt Birkholz <address@hidden>
> Date: Sat, 19 Mar 2005 01:13:29 +0000
>
> [...]
> Given what I have learned this past week, the latter trick looks
> doable. I already have a couple threads (a console REPL and Edwin)
> running, time-sliced, in an idle function of Gtk's main loop, with a
> GTk main window displaying the slice count. A GTk-based select
> registry should complete the picture. Wish me luck?
To integrate Scheme and the toolkit's main loop, I am running Scheme
(the Interpret function) inside a GSource dispatch function. When
Scheme yields to the toolkit, it returns from Interpret. When the
toolkit yields to Scheme, it calls Interpret(1) -- with the
pop_return_p arg #t.
Getting into and out of Scheme this way seems to be working well, but
I do not really understand why PRIMITIVE_CANONICALIZE_CONTEXT is
necessary -- how/why compiled code leaves the stack in a difficult
condition for the interpreter. SO I would like some re-assurance from
the list that my technique is sound.
My technique is to introduce two new "aborts" -- dispatch codes for
abort_to_interpreter. Here is how I have changed interp.c:
*** interp.c.~9.100.~ Thu Mar 6 05:41:19 2003
--- interp.c Tue Mar 22 17:39:29 2005
***************
*** 437,442 ****
--- 437,452 ----
repeat_dispatch:
switch (dispatch_code)
{
+
+ case PRIM_CONTINUE_AFTER_C:
+ PROCEED_AFTER_PRIMITIVE ();
+ return;
+
+ case PRIM_RETRY_AFTER_C:
+ BACK_OUT_AFTER_PRIMITIVE ();
+ Save_Cont ();
+ return;
+
case PRIM_APPLY:
PROCEED_AFTER_PRIMITIVE ();
case CODE_MAP (PRIM_APPLY):
In my modified TEST-SELECT-* primitives (when Scheme yields to the
toolkit for a poll(2)), I do this:
PRIMITIVE_CANONICALIZE_CONTEXT ();
<setup/check GSource>
PRIMITIVE_ABORT (PRIM_RETRY_AFTER_C);
Did my foot get shot?
[MIT-Scheme-devel] callbacks, Chris Hanson, 2005/03/18