chrisa / node-dtrace-provider

Native DTrace probes for node.js apps
Other
321 stars 68 forks source link

Pass extra args to callback via .fire() #82

Closed melloc closed 8 years ago

melloc commented 8 years ago

With this change, extra arguments can be passed to the callback given to .fire(), similar to how functions like setImmediate work. This means that a single top-level function can be passed to .fire(), instead of constructing a new closure each time you call it, which takes additional time and memory. (And might be for naught if the probe isn't enabled.) I haven't done much C++ or Nan before, so if anything here can be improved, please let me know.

This compiles and runs on SmartOS and Mac OS X. All of the tests, including the two I've added, pass on both platforms (except for the 2 JSON ones which get skipped on Mac OS X). Additionally, I've run the DTrace tests in trentm/node-bunyan using these changes.

trentm commented 8 years ago

@davepacheco Would you be able to take a look at this at some point? (Asking because you are one of the owners).

melloc commented 8 years ago

@davepacheco I've updated the README based on your suggested paragraphs. Let me know if you think it can be improved.

melloc commented 8 years ago

(There was a minor issue with one of the examples I wrote. I've fixed it and updated the branch.)

melloc commented 8 years ago

I've tested this on SmartOS and Mac OS X. Once I added the fix for chrisa/libusdt#12, all tests passed on Mac OS X and SmartOS. Results are below.