01-05-03 18.48, skrev Doug MacEachern p� [EMAIL PROTECTED] f�ljande:
> On Thu, 3 May 2001, Artur Bergman wrote:
>
>> does :shared work in bleadperl? attrs.pm doesn't seem to have a clue about
>> it? There are two issues here as I see it.
>
> the shared attribute works in bleedperl, but it does not mean what you
> think it means. search the archives for GvSHARED, in particular:
> http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-02/msg00535.html
> in a nutshell, GvSHARED GVs are not copied across perl_clone, and
> piggyback the existing SvREADONLY checks for memory
> savings. these `shared' GVs cannot be written to once marked as GvSHARED.
Unless one unmarks them and protect them using Mutexes. (just turn of
readonly)
>
> sharing SVs between interpreters that can be written to is much more
> difficult problem. i believe dick hardt coined the term 'solar variable'
> for this concept. solar is global variable that is visible to all
> interpreters.
>
> i have fiddled with 'our $foo : solar;' using tie (sv_magic). with a
> structure along the lines of:
> typedef struct {
> perl_mutex lock;
> SV *var;
> } solar_t;
>
> tie like so:
> static void solar_scalar_tie(pTHX_ SV *rv)
> {
> SV *sv = (SV*)SvRV(rv);
> SV *obj = newSV(0);
> sv_setref_pv(obj, "solar::scalar", (void*)solar_new(aTHX));
> sv_magic(sv, obj, 'q', Nullch, 0);
> }
>
> when $foo is copied by perl_clone() it gets a pointer (not copied) to
> the solar_t returned by solar_new. FETCH and STORE then use the
> solar_t.lock to serialize access to the solar variable. what i have works
> ok for simple scalars, but dealing with complex structures is, well,
> complex. each value of a hash and array would need to be tied, if those
> values are hashes or arrays, their values need to be tied, and so on.
> so yes, there are performance problems. i have not investigated howto
> implement solar variables in the core. however, that approach would need
> to take special care not to add overhead to the core for all things
> non-solar.
Do you have the code that does this avaible somewhere?
Artur