On Fri, Sep 2, 2016 at 1:53 PM, Saúl Ibarra Corretgé <[email protected]> wrote:
> On 02/09/16 19:31, J Decker wrote: > >> >> On Thursday, September 1, 2016 at 12:54:20 AM UTC-7, Saúl Ibarra >> Corretgé wrote: >> >> On 09/01/2016 01:06 AM, J Decker wrote: >> > I'm working on a simple network proxy addon for node (yes it's >> sort of a >> > crossover issue, but the error happens in ... hmm no adding run >> fixed >> > that... moved the problem I guess >> > >> > I cut out most of the excess code; there's still excess in the >> > custructor callback... but I wanted to leave that flow intact. >> > >> >> Was there a previous email I missed? I have no context thus far. >> >> No; that's about all the context I can give? I can provide a more >> complete example, and probably should. >> Unfortunatly I'm under windows at the moment, so I don't even know what >> the callback stack looks like; working on building it under linux today... >> >> > Your email sounded like a conversation with someone, and I thought I was > just getting one side of it :-P > > >> > when creating a new object, I create a single uv_default_loop() that >> > I'll never close ? >> > >> >> That's going to be a problem. Node itself uses the default loop, so >> you'd be using the same loop really, and uv_run is non-recursive, so >> you >> cannot call it while it's already running, and it is, otherwise your >> JS >> code wouldn't run. >> >> >> uv_run is only called during garbage collection, which should be the >> same thread that is the javascript? >> > > Yes, but that's incorrect, you should not call uv_run yourself. the previous message on this group specifes you must after calling close. (I see but if I never close the async, and of course I can't use data for anything useful and it might as well be null and just reference a static container that contains a queue with the object who's callback is to be called for the message received? > > > why would one want to use multiple loops? and add a loop per async then? >> >> > It depends on the use case. In yours, you probably want multiple async > handles. > > I really think I do.... but if I don't call run after close it libuv genrates an assert(0) ; yes I'm running a debug build and if I built it release it wouldn't crash? But if I continue and ignore the assert it does crash anyway. > >> > on destructor I do uv_close( (uv_handle_t*)&async, NULL ); >> > uv_run( fbdl.loop, UV_RUN_DEFAULT ); >> > >> >> As mentioned above, bad idea. Even if you use a new loop, why? Why >> not >> use the existing loop? Are you also using other threads? >> >> So I shouldn't use multple Async objects each with their own .data >> referencing a object? >> > > Yes. > > You just said 'you probably want multiple async handles' and to 'so I should NOT use multiple async objects" you say yes? I phrased it differently so I could get a clear answer. > is the exsting loop ' get_default_loop()' so I shouldn't close it? I >> never do? >> >> > Yes, you can get it from the current Environment object, then call > event_loop() on it. Example: https://github.com/nodejs/node > /blob/1b99093df78b795052c944fc6388a934e84e89ef/src/timer_wrap.cc#L99-L100 > > Never close the loop, Node does it on its own. > > "I never do. " sorry the question mark was ... sarcasm/rhetoric. but ok I can use the one from the environment. > > -- > Saúl Ibarra Corretgé > http://bettercallsaghul.com > > > -- > You received this message because you are subscribed to a topic in the > Google Groups "libuv" group. > To unsubscribe from this topic, visit https://groups.google.com/d/to > pic/libuv/XXOovowH8EE/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/libuv. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
