Skip to content

@rjack /index.html
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Unstoppable Web Worker
<!DOCTYPE>
<html>
<head></head>
<body>
<p>Start the worker from the browser console (fire up a CPU monitor to
have some sort of visual feedback)</p>
<pre>worker.postMessage("run")</pre>
<p>you will NOT be able to stop it with</p>
<pre>worker.postMessage("stop")</pre>
<p>What I'd expected:</p>
<pre>worker.postMessage("run") // start
worker.postMessage("stop") // stop
worker.postMessage("run") // start from where it was interrupted</pre>
<script type="text/javascript">
var worker = new Worker("worker.js");
</script>
</body>
</html>
var count = 0,
running = false,
iface = {};
iface.run = function ()
{
running = true;
while (running) {
count++;
}
};
iface.stop = function ()
{
running = false;
};
onmessage = function (ev)
{
var func_name = ev.data;
iface[func_name].apply();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.