<div dir="ltr"><div style>I&#39;m looking into this now, but there are a few modifications you can make to eliminate some blocking calls, namely: </div><div style><br></div><div style>sph-list is a list, and you are using for/fold to iterate over the elements in the list (inside a future). This is problematic for a number of reasons; instead, you could convert it to a vector (or just change your definition to use a vector) and change `ray-cast&#39; accordingly:</div>
<div style><br></div><div style><div>(define (ray-cast x y object-list)</div><div>  (let ([view-ray (screen-ray x y)])</div><div>    (define closest-int (int-res #f 10000.0 null-point))</div><div>    (for ([i (in-range 0 (vector-length object-list))])</div>
<div>      (define obj (vector-ref object-list i))</div><div>      (set! closest-int (get-closer-res closest-int</div><div>                                        (hit-sphere3D view-ray obj))))</div><div>    closest-int))</div>
<div><br></div><div style>Also, there are two places where I think you may have forgotten to use flonum primitives (on lines 99 and 100) -- just change `sqrt&#39; to `flsqrt&#39;, as you have done elsewhere in the code.  </div>
<div style><br></div><div style>This doesn&#39;t eliminate all the blocking behavior, however -- I still see a few `values&#39; blocking calls, and allocation as well.  I&#39;ll spend some more time looking through it and report back to you. </div>
<div style><br></div><div style>Cheers, </div><div style>James</div></div><div><br></div><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Date: Fri, 22 Feb 2013 00:03:28 +0300<br>
From: Dmitry Cherkassov &lt;<a href="mailto:dcherkassov@gmail.com">dcherkassov@gmail.com</a>&gt;<br>
To: <a href="mailto:users@racket-lang.org">users@racket-lang.org</a><br>
Subject: [racket] values primitive blocks future execution<br>
Message-ID:<br>
        &lt;CAN0j1dRCGY7A2WxXBYXP=<a href="mailto:JbLntw_-L3O7eoYJvD1VTAb%2BqDLYQ@mail.gmail.com">JbLntw_-L3O7eoYJvD1VTAb+qDLYQ@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
<br>
Hi list.<br>
I&#39;ve been doing a simple ray tracer[1] and decided to parallelize it using<br>
futures.<br>
<br>
I&#39;ve tried to use flonums everywhere and added (in-range) to loops [3]<br>
(over x and y coordinates).<br>
<br>
The problem is that execution of future is blocked seriously.<br>
(apparently by the value primitive) [2]<br>
<br>
Are there any ideas why it doesn&#39;t work?<br>
<br>
I use racket v5.3.3.<br>
<br>
[1] Complete source code: <a href="http://pastebin.com/EGSzR1Tv" target="_blank">http://pastebin.com/EGSzR1Tv</a><br>
<br>
[2] Future visualizer screenshot: <a href="http://ompldr.org/vaGpiaQ" target="_blank">http://ompldr.org/vaGpiaQ</a><br>
    Invoked via<br>
    (require future-visualizer)<br>
    (visualize-futures (run-no-render))<br>
<br>
[3] Source code for main loop:<br>
(define (render-scene-dummy object-list)<br>
  (let* ([f (future<br>
           (lambda ()<br>
             (for* ([x (in-range (/ screen-width 2))]<br>
                    [y (in-range screen-height)])<br>
               (let* ([ray-res (ray-cast x y object-list)]<br>
                      [pix-col (point-col (int-res-p ray-res))])<br>
                 #t))<br>
             ))])<br>
<br>
    (for* ([x (in-range (/ screen-width 2) screen-width)]<br>
           [y (in-range screen-height)])<br>
      (let* ([ray-res (ray-cast x y object-list)]<br>
             [pix-col (point-col (int-res-p ray-res))])<br>
        #t))<br>
    (touch f)))<br>
<br>
<br>
<br>
--<br>
With best regards,<br>
Dmitry<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: &lt;<a href="http://lists.racket-lang.org/users/archive/attachments/20130222/6e2262a8/attachment-0001.html" target="_blank">http://lists.racket-lang.org/users/archive/attachments/20130222/6e2262a8/attachment-0001.html</a>&gt;<br>
<br></blockquote></div></div></div>