Created
April 23, 2015 20:37
-
-
Save falsecz/f0be5e54d3cf8bf2e6e1 to your computer and use it in GitHub Desktop.
async breakout
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
## coffee --nodejs --expose-gc index.coffee | |
### | |
sam autor asyncu pise ze se to ma udelat takhle | |
https://github.com/caolan/async/pull/85#issuecomment-13072390 | |
or just use a named function for the final callback and call that instead | |
of the task callback passed into the successful task function. | |
### | |
mem = () -> Math.floor(process.memoryUsage().rss / 1024 / 1024) | |
logmem = (o) -> console.log mem() + " MB " + o + " " + (mem() - startmem ) + " MB" | |
startmem = mem() | |
async = require 'async' | |
test = (testdone) -> | |
logmem "pred taskama" | |
tasks = [] | |
tasks.push i for i in [1..10000000] | |
logmem "tasky v pameti" | |
findSeries = (series, done) -> | |
async.eachSeries series, (s, next) -> | |
return done null, s if s is 10 # vyskocim z asyncu kdykoliv potrebuju | |
setTimeout (() -> next()), 0 | |
, done | |
findSeries tasks, () -> | |
console.log arguments | |
testdone() | |
test () -> | |
logmem 'tesne po dobehnuti' | |
setInterval () -> | |
global.gc() | |
logmem 'po gccku' | |
, 1000 |
Author
falsecz
commented
Apr 23, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment