# Advice on a simple parallel task pattern(Beginner question)

**URL:** <https://discourse.julialang.org/t/advice-on-a-simple-parallel-task-pattern-beginner-question/97>\
**Category:** General Usage\
**Created:** [November 3, 2016, 8:48am UTC](https://discourse.julialang.org/t/advice-on-a-simple-parallel-task-pattern-beginner-question/97 "2016-11-03T08:48:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TsurHerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tsurherman/32/1234_2.png) [@TsurHerman](https://discourse.julialang.org/u/TsurHerman)\
**Post date:** [November 3, 2016, 8:48am UTC](https://discourse.julialang.org/t/advice-on-a-simple-parallel-task-pattern-beginner-question/97/1 "2016-11-03T08:48:28Z")

</div>

Hi ,

I am trying to achieve a perfect looking translucency effect in openGL for an AR headset.  
For that matter I need to sort the triangle faces every time the view point changes, since this is a live headset  
it means that I need to do it every frame I am rendering, moreover I want to render in at-least 60 fps.

So beyond a certain amount of triangles it is not feasible, and I would like to defer that task to a parallel task.

My data is V,N,F,Pos (Vertices,Normals,Faces,Position)

The naive non-parallel render loop looks like this:

```julia
while true
    F_Sorted = sortfaces(V,F,Pos)
    drawtriangles_indexed(V,N,F_sorted,Pos)
end

```

I am sure there is a super simple way of running the sortfaces function in a parallel task, I am struggling  
a little bit with the documentation trying to discern whether I need a task @async or @spawn or channel.

Any comment is appreciated

---

<div class="post-metadata">

**Author:** ![TsurHerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tsurherman/32/1234_2.png) [@TsurHerman](https://discourse.julialang.org/u/TsurHerman)\
**Post date:** [November 9, 2016, 6:31pm UTC](https://discourse.julialang.org/t/advice-on-a-simple-parallel-task-pattern-beginner-question/97/2 "2016-11-09T18:31:01Z")

</div>

O.k I’ll answer myself.

It is indeed super simple:

```julia
F1= @spawn sortfaces(V,F,Pos)
if isready(F1)
    F_sorted = fetch(F1)
end

```

Need to make sure that there are enough processes running.
