🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #40724

Re: Embedding Perl into a threaded program

#40724
From: Andrew
Date: Sat, 09 Oct 1999 00:00
51 lines
2777 bytes
In article <yl7lkwpdqv.fsf@windlord.stanford.edu>, Russ Allbery wrote:
>Well, for what it's worth, one of the Perl threading experts backed up my
>memory of how the Perl folks think it works and what their experiences
>have been.
>
>What version of Perl did people here try it with?

5.005_03.

>From: Dan Sugalski <dan@tuatha.sidhe.org>
>Newsgroups: comp.lang.perl.moderated
>Subject: Re: Embedding Perl into a threaded program
>Date: Sat, 09 Oct 1999 17:45:22 GMT
>
>Russ Allbery <rra@stanford.edu> wrote:
>> My understanding from previous discussion here and on p5p is that Perl
>> (even when not built threaded itself) can be safely embedded into a
>> threaded program provided that only one thread instantiates and talks to
>> the interpretor and the other threads keep their hands off and route all
>> communication to the embedded Perl code through that one thread.
>
>As long as only one thread is in *any* perl interpreter at any one time,
>you can safely embed perl in a threaded app. Perl itself really doesn't
>care about what OS thread is executing it.

And provided Perl is not using its own malloc, or otherwise providing
non-thread-safe replacements for any system functions.

>> I've now gotten a report that another person had no end of trouble doing
>> this.
>
>There was probably something else going on. He might have built with
>MULTIPLICITY and assumed you were OK as long as no two threads were in the
>same interpreter but it was OK to have two threads in two separate
>interpreters at the same time or something. (An assumption that's not
>true, BTW)

No; only one interpreter was involved. Access to that interpreter was
controlled by a single mutex lock.

>The only place I can see you getting in trouble is if one thread allocates
>a perl data structure on its stack (naughty, naughty thread!) and hands it
>off to perl.

Nope; nothing like that going on.

-- 
Andrew, Supernews
http://www.supernews.com - UK and US individual and corporate NNTP services

Technical Details
Message-ID: <slrn7vv7lv.4tj.andrew+news@uk21.supernews.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <yl7lkwpdqv.fsf@windlord.stanford.edu>

Show Full Headers
Complete Article Headers
Message-ID: <slrn7vv7lv.4tj.andrew+news@uk21.supernews.com>
Subject: Re: Embedding Perl into a threaded program
Date: Sat, 09 Oct 1999 00:00:00 +0000
From: andrew+news@supernews.com (Andrew)
References: <yl7lkwpdqv.fsf@windlord.stanford.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 534791200
X-Complaints-To: newsabuse@remarq.com
X-Trace: 939499199 .MYBPHMNN00017F00C uk21.supernews.com
Organization: RemarQ http://www.remarQ.com
User-Agent: slrn/0.9.5.4 (UNIX)
Reply-To: andrew@supernews.com
Newsgroups: news.software.nntp