Created
May 16, 2016 20:09
-
-
Save griffinmichl/42e449098db9e065f36a0d2f664f5e1c to your computer and use it in GitHub Desktop.
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
const task1 = done => setTimeout(_ => {console.log('1'); done()}, 100) | |
const task2 = done => setTimeout(_ => {console.log('2'); done()}, 50) | |
const task3 = done => setTimeout(_ => {console.log('3'); done()}, 25) | |
const taskRunner1 = queue(1) | |
taskRunner1.push(task1) | |
taskRunner1.push(task2) | |
taskRunner1.push(task3) | |
// 1 | |
// 2 | |
// 3 | |
const taskRunner2 = queue(2) | |
taskRunner2.push(task1) | |
taskRunner2.push(task2) | |
taskRunner2.push(task3) | |
// 2 | |
// 3 | |
// 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment