[plt-scheme] newbie question: returning values from threads

From: Kirk Miller (kmiller3cop at yahoo.com)
Date: Tue Jun 15 19:15:16 EDT 2004

I am trying to access multiple xml-rpc servers in
parallel since each call takes a long time. I don't 
know how to propagate the answer back out of a thread.
I make a call starting a thread for each host.
Then I wait for the thread to join and return a
list of strings. But in this case "result" is always
'(). I think its a synchronization thing. In previous
attempts I have pre-created a list
of outports to hold displayed data, but I want to know
how to get a list back instead of having to read
ports. (the program should be more generally useful)

  (define result '())
  (define (get-host host) 
    ; in= string: host
    ; out=(cons (tid los))
        (lambda ()
          (let (
                (server (xml-rpc-server host 8000
            (set! result (cons host
                               ((server 'sm50)))))))

  (define (sm66 hostlist)
    (let ((tid-los
            (lambda (h)
              (get-host h))
       (lambda (t)
         (thread-wait (car t))
         (cdr t))

Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.

Posted on the users mailing list.