develooper Front page | perl.ithreads | Postings from August 2002

Re: Thread-Tie-0.01

Thread Previous | Thread Next
From:
Elizabeth Mattijsen
Date:
August 10, 2002 01:58
Subject:
Re: Thread-Tie-0.01
Message ID:
4.2.0.58.20020810105545.06479360@mickey.dijkmat.nl
At 12:23 AM 8/10/02 +0200, Arthur Bergman wrote:
>>Shared variables in this approach are truly shared.  The value of a variable
>>only exists once in memory.  This implementation also circumvents the memory
>>leak that currently (threads::shared version 0.90) plagues any shared array
>>or shared hash access.
>You will find that this is not true :-(, mostly because of perl deals with 
>tieing.
>
>Perl will always copy the result from a tied call into the variable that 
>is tied.
>
>so in effect
>
>tie $foo, "Tie";
>
>sub Tie::FETCH {
>         return "hi";
>}
>
>will result in
>
>print $foo;
>
>not being print tied($foo)->FETCH(); but rather that it will be
>
>$foo = tied($foo)->FETCH; print $foo;
>
>so before every access to the tied object, FETCH is called and the return 
>value is copied into the tied variable which is then used as a normal perl 
>variable.
>
>this is why I want to replace magic with PMC, this is also why tied 
>variables are 2x as slowas doing tied($foo)->FETCH directly

Ah..  ok...  I didn't know that.

But at least the value will only be copied to the thread that actually 
requests it, so that is a saving I would think?



Liz


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About