Replies: 1 comment
-
Hi @nextfool, As you point out, However, ClearScript currently provides no special treatment for Exposing foreign script objects isn't something we recommend. In addition to overhead, deadlock becomes a point of concern, as each script engine has its own internal mutex. Furthermore, proxying a
No. A To support your scenario, ClearScript needs an enhancement whereby exposing a foreign Thank you very much for making us aware of this! UPDATE: We've created Issue #317 to track the implementation of this enhancement. |
Beta Was this translation helpful? Give feedback.
-
Hi community,
I have some questions regarding implementing the "SharedArrayBuffer" and "Worker" with clearscript.
As we know that, the "SharedArrayBuffer" is among the "javascript standard built-in objects" along with "Atomics api"
But "Web worker" is part of the "web api" which is implemented in the "browser" side, so there is NO native V8 support of it.
Thanks to @ClearScriptLib , they have this nice worker implementation example available.
But now the dilemma is that, the SharedArrayBuffer and Workers usually work together:
To my understanding, the above code, will run in two different "contexts", while the worker runs at the "c# side", the "SharedArrayBuffer" runs at the "native v8 side". To handle the posted message at the "c# side", I need to get the reference of the "SharedArrayBuffer" which is basically a pointer to a physical memory address (point me out if I was wrong)? Well the problem is, I just can not get the "pointer" value as it is hidden deep in the private field inside some v8 native objects.
So now I guess I have two options:
If there is any way which allows me to get the "value of the pointer", so I can pass this "pointer" to the code in a worker, so the javascript code can truly "share memory" within V8's native heep.
If No.1 is not feasible, I am thinking of implementing the "SharedArrayBuffer“ as well as the "Atomics" apis (with c# Interlocked apis") at the "c# side", and "override" the default built-in apis from V8. In this case, performance maybe an issue, as each "atomics" operation will now happen on CLR's "managed heap" (again, please point me out if I am wrong)?
So please help me in every ways, any comment/advice/solution is very much appreciated!
Thank you in advance.
Beta Was this translation helpful? Give feedback.
All reactions