[Vortex] Anybody have binding of vortex into Lua?

Sam Roberts sroberts at uniserve.com
Fri Sep 22 19:46:54 CEST 2006

On Fri, Sep 22, 2006 at 07:10:16PM +0200, Francis Brosnan Blazquez wrote:
> > I like vortex, and I'm hoping to use it in upcoming projects, but
> > its use of threading makes it impossible to bind into ruby [*],
> > which would be my language of choice.
> Not impossible, at least, not directly ;-)

> You can always make the asynchrouns API to be behave synchronously,
> which is the way we use vortex library inside our C# applications. 

> In fact, most of the API is dual (i.e: vortex_connection_new and
> vortex_channel_new don't create threads if no notification handler is
> provided). 

Do you not have to call vortex_listener_wait(), then? It looked to me
like when a connection request came in a callback to C was made, and
that callback had to figure out whether to accept or reject the
connection before returning.

In theory, I would store the callback arguments somewhere, notify the
main ruby thread to wake up (probably write a byte to pipe to wake
up the ruby interpreter's select), the ruby code would then make
vortex calls on those callback arguments (but from a different thread
than that which called the callback), and then pass control back
to the callback. This all seemed quite complex, though, and I'm not
even sure it would work!

That impression was from an afternoons playing with the example code a
fair while ago, though.

> A more evolved approach could be trying to integrate the Vortex into the
> ruby event loop which I don't know if it would be possible [3].

Ruby's event loop is very simple. The rules are:

- Only the one interpreter thread can make ANY calls to ANY ruby APIs.
  No exceptions.

- The interpreter loops on select. When select wakes on i/o readiness,
  it then activates the ruby "thread" that had "blocked" on that fd.
  From ruby, it looks like you have a real o/s thread and do blocking
  calls, but internally those blocking calls are implemented by calls to
  select (or as a "context" switch if other threads are ready).

Give the above, what approach would you suggest?

> Knowing this, will be this enough to try a ruby binding for Vortex and
> build that chat application with ruby? 

I have other reasons for trying lua first. If I had all the time I
wanted, I would also do ruby... but I don't have that much time. I will
see what I can do.

I don't need a chat application, of course, but it seems a good way
to get up to speed on Qt, vortex, and lua. If I can get my lua and Qt
apps chatting over vortex, I can throw the code away and do something


More information about the Vortex mailing list