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.
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to