Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FinalizerCallbacks and threads #1314

Closed
audetto opened this issue Apr 29, 2023 · 2 comments
Closed

FinalizerCallbacks and threads #1314

audetto opened this issue Apr 29, 2023 · 2 comments
Labels

Comments

@audetto
Copy link

audetto commented Apr 29, 2023

I have finally got my c++ addon to correctly memory manage wrapped objects.

What I learned is that the callbacks can only run when the main thread "yields" (e.g. via a setTimeout call) (there is a discussion here https://github.com/orgs/nodejs/discussions/47716).

In plain javascript, this is probably as far as one can go, but I was wondering if using the node (addon) api either of the following items are possible

  1. flag the callback as "threadsafe" so node will run it immediately, rather than schedule it for later
    • no need to callback into node (I just need delete ptr)
  2. tell node to "run all pending callbacks" via a faster node api call
    • as opposed to a await sleep(0) which is not that fast, and makes everything into an async

?

@KevinEady
Copy link
Contributor

This functionality would need to be addressed in the changes we're discussin to the SetImmediate finalizer functionality.

Relates: #1140

@github-actions
Copy link
Contributor

This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

@github-actions github-actions bot added the stale label Sep 11, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants