-
Notifications
You must be signed in to change notification settings - Fork 194
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
Can not resolve NodeJS Promise Concurrently from Java Side #817
Comments
You might be interested in https://mikehearn.github.io/nodejvm/ which has an API and other utilities for synchronizing and scheduling work back and forth between NodeJS and Java. |
I checked your code. and It does the exact same way I provided from work around.
|
I wonder if you have tried https://github.com/caoccao/Javet |
This looks promising, didn't know that. But how can I send message from node to java? It seems I can not inject Java to NodeJS it.globalObject.set("FIII", Fooo())
// Undefined value
val foo = it.globalObject.get<V8ValueUndefined>("FIII") |
Javet has its own universe tailed to Node.js and V8. In your case, you need a proxy converter to set up bi-directional binding. I recommend you to go over the tutorials and you'll get it. The Node.js env is genuine (100% compatible). |
I made node addon module which expose |
It is clear that javascript is not supported under multi thread environment, but I suppose some components should handle multi-thread.
Promise is good option to express concurrent control flow. However in current implementation we can not resolve Promise from different Thread!. (Except for few case)
(1) NodeJS -> Java
Only solution for this situation is to block the nodejs until Java resolve the Promise.
(2) Java -> embedded Javascript
This case is not a problem, since Java developer can synchronize the access to the Context
We cannot queue runnable to the nodejs taskqueue e.g)
setInterval
,setTimeout
,setImmediate
when nodejs is taking control. So we cannot use those method to resolve Promise or queue task to notify the nodejs.NodeJS task queue api and Promise-like object needs to support multi-threading out-of the box.
Creating nodejs worker thread to resolve one promise seems like pretty expensive.
Work Around
I make a workaround using Worker and Blocking Queue.
But it would be nice to use, something that nodeJS event loop can poll it, rather than blocking.
And still can not schedule task to NodeJS
The text was updated successfully, but these errors were encountered: