On Tue, Jun 13, 2017 at 3:37 PM, Super Twang <[email protected]> wrote:
> I've got an event-driven main uv loop, and a thread in which I'm waiting for
> MIDI messages, gathering them into a thread-safe queue and then trying to
> trigger an async callback on the main loop, but my callback in the main loop
> never seems to fire.
>
>
> Here's my callback:
>
> void dataReadyCb( uv_async_t *hdl )
> {
>   assert(0);
>   assert(hdl);
>   assert(hdl->data);
>
>   pxEvThMidiIn *handler = static_cast<pxEvThMidiIn*>(hdl->data);
>   handler->processIncomingMidi();
> }
>
>
> Initializer in the main loop:
>
> uv_async_t myHdl;
> uv_async_init( uv_default_loop(), &myHdl, dataReadyCb );
>
>
> Then the thread starts...
>
> and I call:
>
> sendData()
> {
>    uv_async_t myTmpHdl;
>   uv_async_init( uv_default_loop(), &myTmpHdl, nullptr );
>   uv_async_send( &myTmpHdl );
> }
>
> I can't figure out why my callback isn't ever called, can you?  Am I
> supposed to be sharing the uv_async_t handle with the main loop receiver
> somehow?
>
> Any help would be appreciated!

Yes, you should use the same handle.  Initialize it in the main
thread, call uv_async_send() in the other thread.

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