No, you can only access an Isolate (including Contexts in that Isolate) from a single thread.
On Tue, Aug 4, 2020 at 5:08 PM Paul Maréchal <[email protected]> wrote: > I do have another question before creating another Isolate: Would creating > a new Context (from the main Node Isolate) be suited to work in a thread? > > Le mardi 4 août 2020 à 11:02:25 UTC-4, Paul Maréchal a écrit : > >> Thanks for the pointers! I'll go with creating an Isolate and keep it in >> the scope of the native thread for all my RegExp evaluations. I was eyeing >> shipping a different regex engine already, but thanks to what you wrote >> I'll be able to try using v8's and see if that is enough for me. >> >> Le mardi 4 août 2020 à 06:03:35 UTC-4, Jakob Kummerow a écrit : >> >>> Creating a separate Isolate for RegExp work is certainly possible. >>> Whether it's a good idea depends on your constraints. Things to consider: >>> - creating an Isolate has a cost; you can reduce overhead if you can >>> keep it around for several RegExp evaluations >>> - on the flip side, keeping an Isolate (and its heap) around consumes >>> more memory >>> - you could ship another RegExp engine instead, at the cost of some >>> binary size >>> - depending on how many RegExps you want to evaluate and at what times, >>> you could consider doing that on the main thread in the existing (Node) >>> Isolate, and only do non-RegExp work on the background thread. >>> >>> >>> On Tue, Aug 4, 2020 at 12:38 AM Maréchal Paul <[email protected]> >>> wrote: >>> >>>> Hi Jakob, >>>> >>>> Thank you for the answer. Now that you mention it, even with the >>>> `Local<RegExp> New(Local<String> pattern, Flags flags)` method, I'd need an >>>> isolate to hold the pattern indeed. >>>> >>>> Then I have the following question: Is it a good idea for me to try and >>>> instantiate an Isolate of some sort, and have that run in the native thread >>>> I try to run the regexp into? >>>> >>>> Le lun. 3 août 2020 à 17:44, Jakob Kummerow <[email protected]> a >>>> écrit : >>>> >>>>> A v8::RegExp requires an Isolate. (There are at least two indicators >>>>> for this: (1) the class RegExp derives from Object, as such they are >>>>> JavaScript objects, and JavaScript objects always belong to an Isolate; >>>>> (2) >>>>> Local<>s are used to hold RegExp instances, and Locals are used to refer >>>>> to >>>>> objects on the managed heap, which is part of an Isolate.) >>>>> >>>>> Aside from that, v8::RegExps operate on v8::Strings, which also >>>>> require an Isolate to live in. >>>>> >>>>> >>>>> On Mon, Aug 3, 2020 at 10:37 PM Paul Maréchal <[email protected]> >>>>> wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> I am writing a Node.js addon that does work in a native thread. I >>>>>> need to run a regex match in said thread and I was hoping to use V8's >>>>>> RegExp objects. >>>>>> >>>>>> It is fair to say that I'm not a C++ expert, so I was wondering if >>>>>> anyone had any pointers regarding this? Is it even possible/a good idea? >>>>>> >>>>>> The API I am looking at has a deprecated static method that looked >>>>>> interesting but I don't understand how I am supposed to use the new one? >>>>>> https://v8docs.nodesource.com/node-10.15/d8/da7/classv8_1_1_reg_exp.html#aad5eb4ac27a23660c32f289da9427367 >>>>>> >>>>>> Thanks in advance, >>>>>> Paul. >>>>>> >>>>>> -- >>>>>> -- >>>>>> v8-dev mailing list >>>>>> [email protected] >>>>>> http://groups.google.com/group/v8-dev >>>>>> --- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "v8-dev" group. >>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>> send an email to [email protected]. >>>>>> To view this discussion on the web visit >>>>>> https://groups.google.com/d/msgid/v8-dev/667aed79-f5df-4005-ab55-e079cfc20b92n%40googlegroups.com >>>>>> <https://groups.google.com/d/msgid/v8-dev/667aed79-f5df-4005-ab55-e079cfc20b92n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> >>>>> -- >>>>> -- >>>>> v8-dev mailing list >>>>> [email protected] >>>>> http://groups.google.com/group/v8-dev >>>>> --- >>>>> You received this message because you are subscribed to a topic in the >>>>> Google Groups "v8-dev" group. >>>>> To unsubscribe from this topic, visit >>>>> https://groups.google.com/d/topic/v8-dev/B7tJko0Itnk/unsubscribe. >>>>> To unsubscribe from this group and all its topics, send an email to >>>>> [email protected]. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/v8-dev/CAKSzg3QpALxgBg8d4x1Uc8DENY09xRmhT%2Bjuo%2B_GYpOFDfpgng%40mail.gmail.com >>>>> <https://groups.google.com/d/msgid/v8-dev/CAKSzg3QpALxgBg8d4x1Uc8DENY09xRmhT%2Bjuo%2B_GYpOFDfpgng%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> -- >>>> -- >>>> v8-dev mailing list >>>> [email protected] >>>> http://groups.google.com/group/v8-dev >>>> --- >>>> You received this message because you are subscribed to the Google >>>> Groups "v8-dev" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> >>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/v8-dev/CAOKZV0a-X7RVVrr%3DQ%2B%2B%2Bi0FsCdfXt8VdTGWycofVvXJYyeTdfQ%40mail.gmail.com >>>> <https://groups.google.com/d/msgid/v8-dev/CAOKZV0a-X7RVVrr%3DQ%2B%2B%2Bi0FsCdfXt8VdTGWycofVvXJYyeTdfQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- > -- > v8-dev mailing list > [email protected] > http://groups.google.com/group/v8-dev > --- > You received this message because you are subscribed to the Google Groups > "v8-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/v8-dev/de9de78c-38f2-4dff-8289-2b692f72595cn%40googlegroups.com > <https://groups.google.com/d/msgid/v8-dev/de9de78c-38f2-4dff-8289-2b692f72595cn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAGRskv_S6wJz_LUW5krRfPx%3Dwf4Axqeu9aR04c%3DdLUBpxApxAQ%40mail.gmail.com.
