I don't understand all the technical aspects to this proposal, but I
approve of anything that makes it possible to sanely integrate with
other event loops, especially GUI event loops. I've wanted for years
to write desktop and mobile apps using libuv.
So, the high-level goal of this is to run something like
CoreFoundation's main loop in a thread which notifies the main thread
(libuv based) about events? Or is it the other way around where libuv
runs in the second thread. In either case, the scripting language
with the user supplied callbacks would be in the libuv thread right?
On Thu, Sep 20, 2012 at 8:16 AM, indutny <
fedor....@gmail.com> wrote:
> Hi everyone!
>
> I suggest adding APIs for embedding libuv's loop inside another loop. After
> dealing with CFRunLoop/NSRunLoop (on OSX) and looking at APIs of other UI
> event loops (i.e. Qt), it seems that the only way of embedding uv's loop is:
>
> 1. Starting thread that will wait for events to happen.
> 2. Asking main loop to process those events and fire callbacks in it's
> thread.
>
> First part that should be definitely implemented and exposed is
> uv_wait(uv_loop_t*) function that will wait for events to happen (w/o
> dequeing them from backend). As the second part I propose introducing
> following APIs:
>
> uv_run_embedded(uv_loop_t*, uv_embed_t*) // start thread, that waits for
> events to happen. uv_embed_t contains a callback that will be called once
> uv_wait() call ended.
> uv_poll_embedded(uv_embed_t*) // process available events and run callbacks.
> Should be called in main thread.
> uv_stop_embedded(uv_embed_t*) // stops thread.
>
> The code (Pull Request) for those API changes is there:
>
https://github.com/joyent/libuv/pull/561
>
> Fedor Indutny.
>
> --
> You received this message because you are subscribed to the Google Groups
> "libuv" group.
> To post to this group, send email to
li...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/libuv?hl=en-US.
>
>