can an external make use of pthreads?
briany at qldlearning.com
Tue Feb 24 03:04:21 EST 2009
This is a shot in the dark, but from your description I wonder if Rev
only maintains the callback address until your external returns. Then,
it disposes of something under the assumption that your external
doesn't need it any more, and things start to fail. This would explain
why it works momentarily, but then goes bad. I wonder if it would be
worth digging into libexternal itself and trying to figure out where
things fail. It's also possible that Rev just can't deal with a
callback coming from anywhere but the main thread.
Here's one random idea -- what happens if you call back into the main
thread, and then make the actual Rev callback from there? That way
your main thread insulates Rev from talking directly to other threads,
and still lives in the same thread as the Rev engine.
> 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?
More information about the Use-livecode