On Wed, 26 Aug 2015 at 11:36 Thomas Heller <[email protected]> wrote:

> Well, while we are on the topic perhaps we should mention the downside of
> using Web Workers. For me it has been Data Transfer.
>
> Since you can only transfer JSON type data between workers that usually
> meant you had to pr-str/read-string to roundtrip CLJS data. If you only
> have very small amounts of data that is no problem but read-string is not
> very performant and even something like 1mb of data will eat up enough CPU
> time to drop you below 60fps.
>

If you can use newer browser, you've got Transferrable Object to transfer
binary data with zero-copy.


>
> That might now be worked around with transit though since that is much
> faster. But still if you need to transfer a lot of data between workers you
> might be better of not using them. IE8/9 might also be an issue but even
> Microsoft suggest that you should not support those versions.
>
> Oh and so far I have not seen support for workers in lein-cljsbuild and I
> haven't documented anything in shadow-build so building web worker
> javascript files might actually be something of a mystery to people. To be
> honest I never used them for anything other than toy projects either.
>

Agreed, its probably a bit of work. I guess that since each one has its own
JS context, the simplest way is probably to have two cljs projects: your
main code and your web worker code.

There is Servant: https://github.com/MarcoPolo/servant
What it seems to do is run the same compiled cljs both as the main code and
the webworker code (with some setup/detection code to manage how it should
run). This way both your webworker and main code can call the same
functions. Communicating between them still happens through messages.
I've never actually used it, so my summary may not be great :)


>
> Anyways, I like them. Use them. It is not that hard. :)
>
> Cheers,
> /thomas
>
>
>
> >
> > Why the cynicism? Isn't it true that the only way to make use of
> multiple cores in browser is to use WebWorkers?
> >
> >
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to