Hi Aaron, thanks for your quick and clear reply - I appreciate it a lot.
Just to be certain - in 1), my guess is that the deserialization from the internal representation is executed in the browser thread. So, in terms of user experience, even though 1) may be slower in absolute sense, it may seem faster or at least more fluent in case deserialization by eval is slow as compared to the deserialization performed by Gears? regards, Roland > 1) eval() in worker, serialize js object structure to internal > representation, deserialize internal representation to js object > structure > > 2) copy js string to temp string, copy temp string to js string, > eval() in main thread > > So it seems to me that option 2) would be faster. I'm not sure if it > would matter one way or the other to your app. You'd have to try it. > > - a > > On Mon, Sep 8, 2008 at 12:42 AM, Roland Bouman <[EMAIL PROTECTED]> wrote: > > > 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
