[plt-scheme] v4: object-name of port

From: Robby Findler (robby at cs.uchicago.edu)
Date: Tue Feb 5 10:35:55 EST 2008

I think this is the best thing to do: during the on-execute callback,
create a thread (on drscheme's space) that waits for the user's thread
to die (you can get a handle to the user's thread by using
run-on-user-thread and getting the value of (current-thread)). When it
dies, kill the ocaml process. Something like this (I didn't test this
code, but hopefully it is close enough to give you the idea):

(define/override (on-execute settings run-in-user-thread)
  (super on-execute settings run-in-user-thread)
  (let ([user-thread #f])
     (λ ()
       (set! user-thread (current-thread))))
    (let ([process-info (start-ocaml-process)])
       (λ ()
         (thread-wait user-thread)
         (stop-ocaml-process process-info))))))

where you've defined start-ocaml-process and stop-ocaml-process.

This code has the advantage that it doesn't require DrScheme to be
around for it to work (not that you can easily take advantage of that
at the moment, but perhaps someday).


On Feb 5, 2008 9:28 AM, Aleks Bromfield <aleks at cs.brown.edu> wrote:
> On Tue, Feb 05, 2008 at 09:23:09AM -0600, Robby Findler wrote:
> > Keeping the interactions pane's separate does not require state on the
> > tab. That is state associated with the user's program.
> >
> > But maybe you mean you want to reuse the same ocaml process each time
> > the run button is clicked on a given tab?
> When the run button is clicked, I kill the current ocaml process and
> start a new one. But when something is typed into the interactions
> pane, I reuse the process which was opened the last time that run was
> clicked on the associated definitions pane.
> I think I kept the process state with the tab just because it was the easiest thing to do at the time.
> ~ Aleks

Posted on the users mailing list.