[plt-scheme] newbie question: returning values from threads
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)
see
http://www.cs.utah.edu/plt/mailarch/plt-scheme-2000/msg00137.html
(define result '())
(define (get-host host)
; in= string: host
; out=(cons (tid los))
(cons
(thread
(lambda ()
(let (
(server (xml-rpc-server host 8000
"/servlets/dpmon-server")))
(set! result (cons host
((server 'sm50)))))))
result)
)
(define (sm66 hostlist)
(let ((tid-los
(map
(lambda (h)
(get-host h))
hostlist)))
(map
(lambda (t)
(thread-wait (car t))
(cdr t))
tid-los)))
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail