Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web-Worker with GWT

What's the simplest way of getting a Web-Worker thread loaded with a GWT module?

I am not referring to getting support for Web-Worker in GWT (there are libraries for that) but rather how would generate a GWT module for loading into a web-worker?

I suspect I need a special Linker - is there one available somewhere?

like image 339
jldupont Avatar asked Sep 02 '11 13:09

jldupont


People also ask

Can Web Workers fetch?

Comlink-fetch allows you to use Fetch in a web worker that is exposed through Comlink. Now create an index.

What is a web worker used for?

Web Workers are a simple means for web content to run scripts in background threads. The worker thread can perform tasks without interfering with the user interface.

Can I pass function to web worker?

Limitations of Web Workers worker. postMessage({ string: 'string', number: 0, array: [], ... }); Those value types above can be handled by the structured cloning. However, you cannot send in functions because they can be neither cloned nor transferred.

What is Web Workers API?

Web Workers makes it possible to run a script operation in a background thread separate from the main execution thread of a web application. The advantage of this is that laborious processing can be performed in a separate thread, allowing the main (usually the UI) thread to run without being blocked/slowed down.


2 Answers

Have a look at http://code.google.com/p/speedtracer/source/browse/trunk/src/client/ui/src/com/google/gwt/webworker/ I didn't dig deep but it seems to be that "special linker" you're looking for (the linker is then used for the "hintlet engine" and "breaky" modules of SpeedTracer)

like image 150
Thomas Broyer Avatar answered Sep 18 '22 23:09

Thomas Broyer


There is a library called gwt-ns which includes web worker. Following link is the example using it. http://extremelysatisfactorytotalitarianism.com/blog/?p=645

UPDATE The author of gwt-ns posted a note that he stopped development since 2010, so it's not compatible with recent GWT (like 2.6.1 or later)

NOTE (04 February 2014): gwt-ns hasn't been touched since June 2010 and my understanding is that the Web Worker support does not work in any recent versions of GWT. This is somewhat expected, as it had to reach fairly far into the GWT compiler to work and would have had to make changes as the compiler design changed. The other modules are also likely out of date since permutation selection for these features would need to be adjusted as browsers add support or move support from prefixed to full. Some things might still accidentally work. Feel free to use the code as you please, but be forewarned. I no longer do any GWT development, so if you'd like to get workers working again with gwt-ns as a base, you'll need to fork the code and start a new project (luckily the Apache 2.0 license makes this easy for you).

like image 23
Joel Handwell Avatar answered Sep 18 '22 23:09

Joel Handwell