Hi Alan,

in my tests I found that using buffer transfer is pretty much
immediate (0-2ms) whereas using copies goes up to ~30-40ms (for a 10MB
data buffer) - not the end of the world, but big difference when using
workers for in a realtime context (e.g. animation). In addition to
your message object you only need to specify another array of which
objects to transfer, the onmessage handler stays the same...

;; send
(let [buf (.-buffer (js/Uint8Array. 1e7))]
  (.postMessage worker #js [buf] #js [buf]))

Maybe important to point out: You can't transfer a typed array
directly, only its underlying ArrayBuffer. After transfer the entire
typed array will be unusable by the sender. Any writes to it will fail
silently and reads will produce `undefined`...

Hth!

On 2 May 2016 at 22:28, Alan Moore <kahunamo...@coopsource.org> wrote:
> Nice work Karsten!
>
> I'm especially curious about your experience with moving typed arrays between 
> web workers and the main thread. We use workers for limited purposes now but 
> would like to expand it to include pulling image content from a web socket - 
> now that web sockets inside workers are recently/finally supported in FF.
>
> Alan
>
>
> On Sunday, May 1, 2016 at 5:54:29 PM UTC-7, Karsten Schmidt wrote:
>> Hi everyone,
>>
>> last week I taught 3-day workshop about the above topics and thought
>> some of you might be interested in this workshop report:
>>
>> https://medium.com/@thi.ng/workshop-report-hi-perf-clojurescript-with-webgl-asm-js-and-emscripten-a545cca083bc
>>
>> The source code of the various examples/exercises is available here (a
>> README will be added in the next few days):
>>
>> https://github.com/thi-ng/ws-ldn-8/
>> --
>> Karsten Schmidt
>> http://postspectacular.com | http://thi.ng
>



-- 
Karsten Schmidt
http://postspectacular.com | http://thi.ng | http://toxiclibs.org

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.

Reply via email to