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.

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.


    > 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.

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.


--
Saúl Ibarra Corretgé
http://bettercallsaghul.com

--
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.

Reply via email to