can an external make use of pthreads?

Andre Garzia andre at
Tue Feb 24 01:55:21 EST 2009

Hello Folks,

anyone here knows what happens if you execute some libexternal code
inside a different thread? That is to say, if your external create a
worker thread pool, is there anyway for those threads to tap into
routines such as EvalExpr or GetVariable and the like? I've noticed
strange behaviours here when doing that. Sometimes the call works but
usually it does not. If a child thread can't call any revolution
external code, then, does anyone here with better knowledge about
pthreads, knows if it is possible to make a child thread exchange data
with a master thread, right now, my main thread can call revolution
stuff nicelly, so, if I can at least make the child threads talk with
their parent, then things could be ok.

This is a webserver external, it uses a pool of threads to process the
connections. If it is a static file, then, it knows how to answer on
its own and will not bother revolution engine, but if a dynamic page
is requested, it asks the engine for data thru a callback (or at least
this is the plan). So far, everything runs smooth and the server just
did 2982 requests per second on my LAN but when I call EvalExpr or
SendCardMessage from one of the worker threads, it always come up with
EXTERNAL_FAILURE (but there are some rare cases, usually the first
time a call is made by the first thread, then it sometimes work...)

I was thinking it was some kind of heap corruption due to my poor
string handling but then something just clicked on my mind and I
wondered, would the threads be the ones to blame? I tought threads
shared data, so I thought I'd be safe with them...

anyone can spare a word or two?


-- All We Do Is Code.

More information about the Use-livecode mailing list