Hi all,

just wondering about what the best approach.

Suppose I use the HttpRequest in a workerpool to receive for example
JSON-formatted data from a server. When the response is received, I
can do two things:
1) Have the receiving worker deserialize the responseText to an object
and pass that on to the main thread,
2) Send the responseText to the foreground browser process and do the
deserialization there.

All other things being equal I would prefer to do 1: worker sends
deserialized object back to browser main thread.

However, this made me wonder how data exchange between workers is
implemented. (I am asking this because in the olden days you could
only pass text messages to workers - this made me wonder if some kind
of implicit serialization/deserialization was added later on to
support exhange of structured objects)

I mean, if the 'under the hood' data exchange of objects between
workers is also implemented using some kind of serialization/
deserialization, then perhaps if may be faster to have the worker send
the responseText, and do the deserialization just once (avaoiding the
implicit serialization/deserialization when the worker passes the data
to the main thread)? Or maybe implicit serialization/deserialization
of objects is indeed involved, but executed as part of the background
process, thus not hogging the main thread (which would be the case
when sending the responseText and have it deserialized by the main
thread)?

Please let me know what you think is the best method to go about this.

kind regards,
Roland Bouman

Reply via email to