Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Please refer my previous problem Multiple perl interpretors.... I build the perl with multiplicity option & thread option and it's working now. However we are facing one more problem now. perl forces us to use the perlinterpretor instance as "my_perl" only. If we use other name like "perl_one", and it gives error "Undeclared variable 'my_perl'". I've given here some definitions in perl.h
# define pTHXx register PerlInterpreter *my_perl; # define aTHXx my_perl;
Please let me know if this "my_perl" is default. Please note that i'm createting the perl interpretor instances in the context of threads and calling the perl sub using call_pv(). Please give your comment on this Regards, Poornachandran SM

Replies are listed 'Best First'.
Re: Perl Interpretor name with multiple instances
by AgentM (Curate) on Dec 13, 2000 at 11:02 UTC
    I did say this before, but you weren't paying attention. Look at what you found. It's obvious that the perl.h API is not thread-safe. Nowhere does it actually state that it is thread-safe. If you want to use multiple perl objects, you are sadly reduced to these no-so-worthy function pulled straight from the man pages:
    my_perl = perl_alloc(); perl_construct(my_perl); perl_parse(my_perl, NULL, argc, argv, (char **)NULL); perl_run(my_perl); perl_destruct(my_perl); perl_free(my_perl);
    You can parse any valid perl using this method. Look more at perlembed to see how the API abuses the assumption that there is only one interpreter.

    Remember, Rule #1 of Threading reads: "A library is not thread-safe unless specifically described that it is." Neither EXTERN.h nor perl.h are thread-safe.

    AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.
      Thanks Mr. AgentM, Just i want to confirm if my understanding is correct. Thanks, Poornachandran SM