James Swaine has just announced the availability of futures for mzscheme. Still work in progress, this is the first step in native-thread support for PLT Scheme, in the form of a parallelisation library. More concretely, we learn from the documentation that a future “API represents a best-effort attempt to execute an arbitrary segment of code in parallel”. One creates a future by passing it a thunk, which starts immediately as a parallel process. Non-parallelisable procedures are detected, and cause the independent thread to block until the main thread touches it: one still needs to write some code to orchestrate the parallel gig. A bit rough, but this is just a pre-alpha release: i’m sure things will only get better and better!
As mentioned, this new functionality is only available for mzscheme, so you’ll need to checkout the code from svn and configure the tree with an incantation along the lines of:
$ mkdir build
$ cd build
$ ../src/configure --enable-futures --disable-mred
$ make && make install
That worked for me. Afterwards, i wrote the CPU burner suggested by James:
#lang scheme (require scheme/future) (define (loop) (loop)) (define (run) (for-each touch (for/list ([i (in-range 0 (processor-count))]) (future loop)))) (run)
and, lo and behold,
mzscheme cpu-burner.ss is making my two little cores beat at top speed.
Happy parallel hacking!