yaorg / node-measured

A Node metrics library for measuring and reporting application-level metrics, inspired by Coda Hale, Yammer Inc's Dropwizard Metrics Libraries
https://yaorg.github.io/node-measured/
MIT License
517 stars 52 forks source link

Add ref/unref methods #9

Closed bnoordhuis closed 10 years ago

bnoordhuis commented 10 years ago

Add ref/unref methods so a meter doesn't keep the event loop alive when everything else has quit.

I tried to add a test but I have no idea how to check that with the test framework that you use.

felixge commented 10 years ago

Thanks @bnoordhuis . The ref/unref stuff on interval is node specific? How is it different from clearInterval?

bnoordhuis commented 10 years ago

Cheers, Felix. Yes, it's node-specific; clearInterval() disables a timer while unref() lets the timer keep running but won't prevent the process from exiting when everything else is finished. Basically:

setTimeout(f, 1000);  // this scripts keeps node alive for the next second
setTimeout(f, 1000).unref();  // but this script will exit right away
felixge commented 10 years ago

@bnoordhuis makes sense. do you need a new release for this on npm?

bnoordhuis commented 10 years ago

That would be great, thanks.

felixge commented 10 years ago

https://github.com/felixge/node-measured/commit/43d06e069aa5131634962ecf85dff6af7dd77cc8

bnoordhuis commented 10 years ago

Cheers, Felix.