-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Conversation
Updates addons.markdown to mention AtExit() function. Addresses issue #8324.
### AtExit | ||
|
||
Lets native addons register exit hooks that run after the event loop has quit | ||
but before the VM is killed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be best phrased as "Registers exit hooks that run after the event loop has ended, but before the VM is killed." Also, it would be good to include the arguments, argument types, and a quick code example of how you might
use the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AtExit functions only run in vm, not when main node is exiting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sam-github the documentation is pulled from the text of the commit that introduces the function -- I think it runs right before the process ends.
Updated description, added arguments and arguments types, and quick code example.
How about: Registers exit hooks that run after the event loop has ended, but before the VM is killed.
The file
Test in JavaScript by running:
|
@sjsharp great work! The only other thing I'd add is a list of the arguments after the function definition -- something like we do for javascript: ### void AtExit(callback, args)
* `callback`: `void (*)(void*)` - A pointer to the function to call at exit.
* `args`: `void*` - A pointer to pass to the callback at exit. |
Like this? void AtExit(callback, args)
Registers exit hooks that run after the event loop has ended, but before the VM is killed. Callbacks are run in reverse order of registration, i.e. newest first. AtExit takes callback
The file
Test in JavaScript by running:
|
Yep, looking good. |
Incorporated latest suggestions.
Pushed changes to patch-1 branch on sjsharp/node. |
Run |
Future note to whoever merges this: Add the following in the commit message:
|
What is the status here? Why it was not merged? This function is very handy for addons to cleanup resources, and it's still undocumented. |
IIRC it was because it |
Updates addons.markdown to mention AtExit() function. Addresses issue #8324.