Skip to content

Commit

Permalink
Improve CPU.pause() functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
nelhage committed May 30, 2011
1 parent e40f10c commit c2db964
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion CPU.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,21 @@ var CPU = {
CPU.run_timer = setTimeout(CPU._run, 0);
},

running: function() {
return CPU.run_timer !== null;
},

_run: function() {
if (!CPU.run_timer)
return;
var i = 0;
while (i++ < 1000 && !CPU.halt)
CPU.step();
if (CPU.halt) {
if (CPU.clock)
clearInterval(CPU.clock);
if (CPU.config.halt) CPU.config.halt();
if (CPU.config.halt)
CPU.config.halt();
} else {
setTimeout(CPU._run, 0);
}
Expand Down

0 comments on commit c2db964

Please sign in to comment.