0.0.2 • Published 2 years ago

@u7/pool v0.0.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

@u7/pool

Use

→ test/index.coffee

#!/usr/bin/env coffee

> @u7/pool > Pool
  await-sleep:sleep

pool = Pool 5

job = (n)=>
  console.log n
  await sleep 100*n
  console.log 'done\t',n

n = 0
while ++n<10
 await pool job,n

await pool.done

output :

→ out.txt

1
2
3
4
5
done	 1
6
done	 2
done	 3
done	 4
done	 5
done	 6
7
8
9
done	 7
done	 8
done	 9
0.0.2

2 years ago