[Vortex] Rebol Script-Binding / Callback Problem

Francis Brosnan Blazquez francis at aspl.es
Mon Mar 14 12:21:32 CET 2011

Hi Robert,

> Hi, I'm currently writing an Rebol-3 extension for Vortex. Rebol-3
> supports a simple callback interface which I use to communicate
> between Vortex lib and Rebol.
> The problem is that the callback (from an on_accept_handler) crashes
> the Rebo interpreter. I assume this has something to do with
> multi-threading.
> 1. Is there a way to run Vortex without multi-threading?

In essense, no. See [1]. You can reduce worker threads to 1, but you
still have 1 thread for the reader and 1 thread for the sequencer (which
is the writer).

> 2. Is there a way to get back the number of running threads? 

Assuming you mean threads created by a particular vortex context, you
could use [2] + 2 (reader + writer).

> As it's the first callback after a connect, I think there shouldn't be
> any threads running.

Because you need the vortex engine to be working to setup connections,
you'll need at least the vortex reader (1 thread) to receive messages
ack'ing connection creation request and the vortex sequencer (another
thread) to be able to send messages...so you'll find threads working
before creating a connection..

> 3. I used a mutex around the callback code to avoid any multi-thread
> clashes. No effect, still crashes the interpreter.

Ok, I'm not aware about rebol engine details, but it certainly looks
like a threading problem plus the fact you need to acquire some kind of
global interpreter lock to avoid breaking rebol engine...

For example, in python, you can run with several threads, but you can't
touch the interpreter from several threads at the same time...you need
to acquire "permission" to do so. 

If you take a look into py-vortex [3] implementation, you'll find
threads are used with no difference while using plain C vortex, however,
you need to acquire the python global interpreter lock to avoid breaking
python interpreter, ensuring only one thread touches rebol at the same

> 4. Any other ideas what I could try? I want to note that the chance
> exists that the problem is in the Rebol-3 interpreter. I just want to
> track it further down.

Try to follow previous idea...

In the other hand, I wouldn't recommend using pull API for you case,
because you'll need your app to get blocked at the rebol loop, so it can
process all its stuff (graphics, io), and only call vortex from handlers
activated vía the user interface...

The idea is to use vortex as usual, setting its handler, etc, and once
you get called at those handler, you must *do something* before calling
rebol to ensure that thread is the only one touching rebol engine, and
later *do something else* after invocation finished to leave other
handlers and rebol loop interface to continue...

...however this is my impression based on how python, gtk and similar
engines works...

Hope it helps!

> Thanks a lot.
> --
> Robert M. Münch
> http://www.robertmuench.de

[1] http://www.aspl.es/fact/files/af-arch/vortex-1.1/html/implementation.html
[2] http://www.aspl.es/fact/files/af-arch/vortex-1.1/html/group__vortex__thread__pool_g85ffbea844b48d16bd13e912766feaed.html#g85ffbea844b48d16bd13e912766feaed
[3] https://dolphin.aspl.es/svn/publico/af-arch/trunk/libvortex-1.1/py-vortex/src/py_vortex_channel.c 
> _______________________________________________
> Vortex mailing list
> Vortex at lists.aspl.es
> http://lists.aspl.es/cgi-bin/mailman/listinfo/vortex
Francis Brosnan Blázquez <francis.brosnan at aspl.es>
91 134 14 22 - 91 134 14 45 - 91 116 07 57


Este mensaje se dirige exclusivamente a su destinatario. Los datos
incluidos en el presente correo son confidenciales y sometidos a secreto
profesional, se prohíbe divulgarlos, en virtud de las leyes vigentes. Si
usted no lo es y lo ha recibido por error o tiene conocimiento del mismo
por cualquier motivo, le rogamos que nos lo comunique por este medio y
proceda a destruirlo o borrarlo.

En virtud de lo dispuesto en la Ley Orgánica 15/1999, de 13 de
diciembre, de Protección de Datos de Carácter Personal, le informamos de
que sus datos de carácter personal, recogidos de fuentes accesibles al
público o datos que usted nos ha facilitado previamente, proceden de
bases de datos propiedad de Advanced Software Production Line, S.L.
(ASPL). No obstante, usted puede ejercitar sus derechos de acceso,
rectificación, cancelación y oposición dispuestos en la mencionada Ley
Orgánica, notificándolo por escrito a:
ASPL - Protección Datos, C/Antonio Suárez 10 A-102, 28802, Alcalá de
Henares (Madrid).

More information about the Vortex mailing list