Think that I got library which includes cpp classes. And I am serving it on HTTP server on JS. I can reach them over HTTP requests. Lets consider libraries as addons in JS with N-API interface. Think that I got two addons and these are reachable over HTTP request with a specific instance. And addon 1 uses addon 2 in a native way (with #include “addon2.h”).
The concurrency problem arises when:
- I send an HTTP request to Addon 1.
- Simultaneously, I send another HTTP request to Addon 2.
- While Addon 1 is processing, it internally calls Addon 2 via native integration.
This creates a potential conflict or race condition because Addon 2 is being accessed concurrently by both the HTTP request and the native call from Addon 1.
So here is my question; how can I manage this concurrency in a hybrid way for both native and HTTP access?
I’m considering using mutexes as a solution, but this doesn’t seem like a good way to do it. Help me out !!!