-
Notifications
You must be signed in to change notification settings - Fork 5
refactor: threadsafe callbacks #108
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR refactors the callback mechanism to be thread-safe by replacing the Napi::AsyncWorker pattern with Napi::ThreadSafeFunction. The changes consolidate callback handling into a single CallbackWrapper class and add mutex protection for callback map operations.
Key Changes:
- Replaced
AsyncWorker-based callbacks withThreadSafeFunctionfor proper thread-safe callback invocation - Unified
CallbackWrapperandReleaseUpdateCallbackWrapperinto a single polymorphicCallbackWrapperclass - Added mutex protection for callback map modifications during registration
- Implemented proper cleanup of existing callbacks before replacing them
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/native/CallbackWrapper.h | Complete refactor from AsyncWorker to ThreadSafeFunction pattern with data structures for different callback types |
| src/native/main.cpp | Added mutex for callback map protection, updated callback registration functions with cleanup logic, modified callback invocation to use new Call() methods |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|




No description provided.