I think we are talking about the same issues, but we can't seem to get
in sync on the terminology. I'm going to try to get off the
merry-go-round by recapitualting the two approaches.


RFC178
- globals are shared unless localized
- file-scoped lexicals are shared by all code in the file
- block-scoped lexicals can be shared through @_, closures, or sub.


fork() on steroids
Variables are only shared if declared with :shared. If a varible is
not declared with :shared, then each thread gets a separate copy of
the data value.

Example

    my $a;
    my $b :shared;

    $a++;
    $b++;
    $Thread->new(\&foo)->join;
    print $a$b;

    sub foo { $a++; $b++; }

Output: 12


> SWM> - without single thingee access mediation
> 
>       my $a;
> 
>       Perl simply ignores locking. Thread gets the value of the winner
>       in a race condition. Perl does _not_ crash and burn. Internal
>       structures, mallocs, and accesses are properly mutexed.

I don't understand this.
Is $a shared between threads or isn't it?

If it isn't, then every thread has it's own copy of the data value,
and there isn't any need for locking.

If it is, then these two statements seem directly contradictory:
- Perl simply ignores locking. 
- Internal structures, mallocs, and accesses are properly mutexed


- SWM

Reply via email to