Hey.
Good to see someone who knows lots more than I do!
I was really only going to have ONE exact node process. The other is a CEF
browser process. the nodejs process is just to run a script in the background.
I am writing an api to bridge the background to the foreground. its very
trivial, just passing std::string back and forth using a project on github
called channel (its a single-header project).
Here is the example code that I currently use to test nodejs on threading:
struct _Args_t { int arg_c; char** arg_v; } Args;
void* runner(void* data) {
cout << "Args: " << Args.arg_v[0] << endl;
node::Start(Args.arg_c, Args.arg_v);
return NULL;
}
int main(int argc, char *argv[]) {
// Init the struct.
Args.arg_c=argc;
Args.arg_v=(char**)argv;
cout << "..." << endl;
pthread_t thatOtherThread;
pthread_create(&thatOtherThread, NULL, runner, NULL);
pthread_detach(thatOtherThread);
sleep(5);
return 0;
}
As you see, I am currently, as this is just testing, only spawning a thread,
tryign to pick up a function that launches nodejs. I want to optimize the code
later, but that should do for now, ot find out what I need to change in general.
Since v8 seems to complain about the way its launched, what can I change in
node.cc->node::Start() to make it work nicely?
Kind regards, Ingwie
Am 20.03.2014 um 12:44 schrieb Ben Noordhuis <[email protected]>:
> On Thu, Mar 20, 2014 at 12:20 PM, Kevin Ingwersen
> <[email protected]> wrote:
>> I just want nodejs to run in a separate thread. Threads are not processes, I
>> am aware. But if I had a possibility to create an isolate that only worked
>> in that separate thread, would that work?
>> I mean, you say that I can make an isolate depend on that other thread,
>> instead of the main one.
>> To be honest, I dont know how thread-safe nodejs is, I just know that it
>> tries to be, by using Lockers and the like.
>
> The Locker in src/node.cc is there to be nice to add-ons*. As someone
> who has maintained node.js for years, let me assure you that node.js
> is not thread-safe at all. (Okay, that's not actually assuring, is
> it? It's still true, though.)
>
> The best you can achieve with the current code base is to call
> node::Start() from another thread - once! - and pin it to that thread
> for the lifetime of the process. Anything else will blow up sooner or
> later.
>
> * node-fibers in particular, it needs a top-level Locker to work correctly.
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.