in reply to Perl as embedded script language

Trying to make your Perl scripts non-blocking preprocessing their source... well, I don't think it is a good idea, at least if you want your scripts to support the language fully and not just a subset. This should be done at the C level, inside the interpreter.

Coro does half of it, running several perl threads inside the same system thread, the missing part is to rewrite the internal perl opcodes that can block to be non-blocking... though, I don't think this will be easy either.

In any case, there are languages that natively support this thread model, for instance Python or Stackless Python or Oz that you should also check.

update: very similar to Coro but at the C level is the GNU pth package. At first look, porting perl to run over this library doesn't look as complex as the alternatives. The idea would be to have several pth-threads at the C level and one independent perl interpreter running inside every one.

Replies are listed 'Best First'.
Re^2: Perl as embedded script language
by james2vegas (Chaplain) on Sep 05, 2009 at 09:11 UTC
    Using Perl and Coro does seem to be the way to go, load Perl + Coro into your application, have each script you need to run be a separate Coro thread (really just a perl context), and when it calls back into your code, suspend that specific thread and unsuspend it on return from your code. You should still avoid Perl code that blocks for other reasons but it wouldn't block on calling back into your code.