I currently have 2 web workers setup like this:
gpsThread = new Worker("js/workers/gpsd_poll.js");
gpsStarted = true;
gpsThread.onmessage = function(event) {
if (event.data !== "") {
do lots of stuff here.....
}
}
netThread = new Worker("js/workers/net_poll.js");
netStarted = true;
netThread.onmessage = function(event) {
if (event.data !== "") {
do lots of stuff here.....
}
}
When gpsThread receives a message and processing, netThread must wait until gpsThread has completed before it begins its callback.
Is there anyway to make them run 'concurrently'? I have tried nesting them together like this:
gpsThread = new Worker("js/workers/gpsd_poll.js");
gpsStarted = true;
netThread = new Worker("js/workers/net_poll.js");
netStarted = true;
gpsThread.onmessage = function(event) {
netThread.onmessage = function(event) {
if (event.data !== "") {
do lots of stuff here.....
}
}
if (event.data !== "") {
do lots of stuff here.....
}
}