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

Re: [plt-scheme] Call/cc problem



Unless you need to handle repeated responses to the same call from A
to B or you need to handle the responses out of order, I would
call (make-icmd (read)) from within send/sync-command.  That will block
until B, the other OS process, sends the response.

If you want to figure out why your program doesn't work anyway, then 
check that send/sync-command is always called from the same thread as
global-command-handler.

Paul

At Wed, 12 Jun 2002 22:29:43 +0200, Erich Rast wrote:
> >In MzScheme, continuations may only be invoked by the same thread that
> >created them.  That's probably why you received the error message
> >   "continuation application: attempted to  cross a continuation boundary".
> >There are a few other places that set continuation boundaries, too, though.
> >
> >Why can't A block on a semaphore until it receives an response from B?
> 
> Sorry, there was a similar reply on Usenet (posting to 
> comp.lang.scheme finally worked).
> 
> My post was misleading: A and B are different *operating system 
> processes* or in other words different end-user applications. B is 
> not written in MzScheme.
> 
> B talks to A like if a user was typing into MzScheme (A) running in 
> an interactive shell. It's a nasty hack... and it just doesn't work 
> because I've made some error, I guess.
> 
> Perhaps the code does help. It probably contains a stupid and 
> extremely obvious error:
> 
> (define (send/sync-command command)   (call/cc    (lambda (cc) 
> (send wp:Continuation-Table            store-command-continuation! 
> command cc)       (send-command command)      #t))   (display 
> "Send/sync body")(newline))
> 
> (define (global-command-handler data)   (let* ((command (make-icmd 
> data))          (continue (send wp:Continuation-Table 
> handle-command                   command)))     (if continue 
> (continue command)         (begin           (print (icmd-data 
> command))           (newline)))))
> 
> wp:Continuation-Table% is a class that currently is just a wrapper to 
> a hash-table. Handle-command returns the continuation, or #f if its 
> argument is not a reply to a previous command.
> 
> Any ideas?
> 
> Regards,
> 
> Erich