Matt Sergeant wrote:
> 
> On Thu, 04 Nov 1999, Jeffrey Baker wrote:
> > I'm assuming that Perl itself is reentrant, since it has been embedded
> > in multithreaded environments before (IIS).  Hopefully someone can
> > comment on that.
> 
> This work was based on PERL_OBJECT support, which is currently only
> available on windows. It's a perl interpreter wrapped up in a C++ object so
> that the whole thing is reentrant. For 5.6 I believe a similar
> functionality but in C is being added (or is moving out of experimental
> mode) called MULTIPLICITY.

I believe -DMULTIPLICITY is already in 5.005_03.  Check "man perlembed".


       Now suppose we have more than one interpreter instance
       running at the same time.  This is feasible, but only if
       you used the -DMULTIPLICITY flag when building Perl.  By
       default, that sets PL_perl_destruct_level to 1.

       Let's give it a try:

        #include <EXTERN.h>
        #include <perl.h>

        /* we're going to embed two interpreters */
        /* we're going to embed two interpreters */

        #define SAY_HELLO "-e", "print qq(Hi, I'm $^X\n)"

        int main(int argc, char **argv, char **env)
        {
            PerlInterpreter
                *one_perl = perl_alloc(),
                *two_perl = perl_alloc();
            char *one_args[] = { "one_perl", SAY_HELLO };
            char *two_args[] = { "two_perl", SAY_HELLO };

            perl_construct(one_perl);
            perl_construct(two_perl);

            perl_parse(one_perl, NULL, 3, one_args, (char **)NULL);
            perl_parse(two_perl, NULL, 3, two_args, (char **)NULL);

            perl_run(one_perl);
            perl_run(two_perl);

            perl_destruct(one_perl);
            perl_destruct(two_perl);

            perl_free(one_perl);
            perl_free(two_perl);
        }

-- 
Jeffrey W. Baker * [EMAIL PROTECTED]
Critical Path, Inc. * we handle the world's email * www.cp.net
415.808.8807

Reply via email to