Concurrency – implement parallel execution in scheme

In SiCp Section 3.4 (serializer in scheme) on currency, there is a process called parallel execution, which is described in MIT scheme but not implemented I wonder if anyone has actually implemented it; If not, how to start implementing such a procedure?

http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-23.html#%_sec_3.4.1

Solution

This is how I use racket to implement parallel execution to solve the exercise in Section 3.4 of SiCp:

(define (parallel-execute . procs)
  (map thread-wait
       (map (lambda (proc) (thread proc))
            procs)))

I can't guarantee that it has the same semantics as the parallel execution process defined in this book, but it allows me to solve the practice

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>