Miikka Miettinen <
miikka.m...@gmail.com> writes:
> Hi,
>
> I'm experimenting with a node-webkit app that would display data
> coming from a kind of sensor. A native module receives the data
> through callbacks, and I'd like to forward the data to the node-webkit
> app. The callbacks happen in a different thread, however, and I should
> therefore hold a lock on the V8 isolate during the execution of the
> callback.
>
> If I include the use of a Locker to the "hello world" Node addon
> example [1], it works when compiled with node-gyp and run from the
> command line, but fails with nw-gyp and node-webkit. The error message
> is "Entering the V8 API without proper locking in place". I wonder if
> accessing an isolate from multiple threads is something that can be
> done in node-webkit?
Hello, V8 doesn't support accessing a single isolate from multiple
threads. You are seeing the error message in node-webkit because it uses
a newer version of V8 (than Node v0.10), which is more developer
friendly regarding this warning -- it reports that the lock has been
held by another thread.
https://github.com/rogerwang/v8/blob/nwebkit/src/api.cc#L121
I suggest to post your events from the callback thread to the main
thread, or you can see how other modules are dealing with threads.
--
Roger