[racket] Futures and shared data structure

From: Eduardo Bellani (ebellani at gmail.com)
Date: Mon Dec 20 13:47:38 EST 2010

Hello all

I am trying to understand futures, and I have generated to following
code to see how I would create reader futures. Unfortunately my futures
are not running in parallel and are taking more time that the serial
version. Besides that it seems to capture the vector in a way that it
becomes noncollectable by the GC.

Could anyone give some hints as to why? (my version is "5.0.2" on Linux)

#lang racket

(require racket/future rackunit rackunit/text-ui)

(define DATA (make-vector 99999999 'datum))

(define-test-suite read-from-shared
  (test-suite "with futures"
              (check-equal?
               (time (let ([f (future (λ _ (read-data DATA)))])
                       (touch f)
                       (read-data DATA)))
               (void)))

  (test-suite "no futures"
              (check-equal?
               (time (read-data DATA)
                     (read-data DATA))
               (void))))

(define (read-data some-data)
  (for ([i (in-vector some-data)]) i))

(run-tests read-from-shared)


Thanks

-- 
Eduardo Bellani

omnia mutantur, nihil interit.


Posted on the users mailing list.