Skip to content

Instantly share code, notes, and snippets.

@souenzzo
Created March 6, 2018 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save souenzzo/d3d305725355bb1ab18c69354380a0e4 to your computer and use it in GitHub Desktop.
Save souenzzo/d3d305725355bb1ab18c69354380a0e4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
var atom = {val: 0}
timeout = 1
const f = () => {
let state = atom.val
let dummmy = 0
for (let i = 0; i < 10000; i++) {
// some computation of new state
dummy = i
}
// assign back
atom.val = state + 1
}
setTimeout(f, timeout)
setTimeout(f, timeout)
setTimeout(f, timeout)
setTimeout(f, timeout)
setTimeout(f, timeout)
setTimeout(f, timeout)
setTimeout(f, timeout)
setTimeout(f, timeout)
setTimeout(f, timeout)
setTimeout(f, timeout)
setTimeout(() => console.log(atom), timeout + 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment