Created
January 18, 2016 19:48
-
-
Save kuraga/b0aa3d66fc0620f03b11 to your computer and use it in GitHub Desktop.
Test concurrent call of the same function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var longActionCalled = 0, | |
firstlongActionCallFinished = false, | |
secondRedrawRequested = false; | |
function longAction() { | |
longActionCalled++; | |
switch (longActionCalled) { | |
case 1: | |
render(); // rafs longAction call | |
// I don't know if setImmedite can help here. But now it's not realized. | |
// setTimeout: "code cannot be executed until the thread that called setTimeout() has terminated." | |
setImmediteReally(function () { | |
secondRedrawRequested = true; | |
}); | |
while (!secondRedrawRequested); | |
firstlongActionCallFinished = true; | |
break; | |
case 2: | |
assert(firstlongActionCallFinished); | |
done(); | |
break; | |
} | |
} | |
render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment