Keep It Simple, Stupid | |
PerlMonks |
perlembed: Maintaining Multiple Interpreter Instances in Different Threads on Windows Server 2003by hackdaddy (Hermit) |
on Jan 19, 2006 at 01:18 UTC ( [id://524103]=perlquestion: print w/replies, xml ) | Need Help?? |
hackdaddy has asked for the wisdom of the Perl Monks concerning the following question:
I'm writing a multi-threaded Windows Service in C and I want to create a new Perl interpreter in each thread I create. The problem is that the perlembed docs only show how to interleave two Perl interpreters in one thread.
Has any one created multiple interpreters in different threads under Windows before? I'm not sure if my ActiveState Perl build can support this. I suppose I could run Perl in a new process in the thread instead. It would be cool if I could do this with the ActiveState Perl build without rebuilding. From perlembed docs: "Using -Dusethreads -Duseithreads rather than -Dusemultiplicity is more appropriate if you intend to run multiple interpreters concurrently in different threads, because it enables support for linking in the thread libraries of your system with the interpreter."
Update: I have the multiple threads working (that is, until there is a collision in the Perl code), and I preface the embedded with PERL_SET_CONTEXT(). The first thread may work to completion, but the others are causing access violations in the following Perl functions: perl_parse eval_pv perl_destruct From perlembed docs: "Note the calls to PERL_SET_CONTEXT(). These are necessary to initialize the global state that tracks which interpreter is the ``current'' one on the particular process or thread that may be running it. It should always be used if you have more than one interpreter and are making perl API calls on both interpreters in an interleaved fashion."
Back to
Seekers of Perl Wisdom
|
|