Hi,

On Saturday 13 March 2004 21:44, Dan Sugalski wrote:
> At 9:06 PM +0100 3/13/04, Oli wrote:
> >Dan Sugalski wrote:
> >>>As well as involving much finding of instances, and moving of
> >>>their attribute
> >>>values, this isn't thread safe (please excuse my lack of PASM syntax
> >>>knowledge):
> >>
> >>Yeah, adding an attribute requires a stop-the-world action, as
> >>every object that has the modified class needs to be modified.
> >>That's a non-trivial activity.
> >
> >But, even if we stop everything until all objects got their
> >attribute list updated, any offsets previously obtained via
> >C<classoffset> may still be bogus afterwards. And there is no way
> >for the code that holds the offset to know that either.
>
> Which is a good reason to not cache the attribute offset value, yeah.
> But, then, the PMC can change classes at a whim, sufficiently enough
> to make even the class name invalid. I think we're reasonably safe
> here, since the only place that we'll see a problem is in class
> methods, which limits the damage.
Renaming the class is already possible.
Maybe its better if classname returns a copy of the string?
The attached program prints Bar, not Foo.

> I could certainly see fit to have a way to get a PMC rather than an
> INT that represents the class, and make sure the magic always updates
> the PMC to have the correct value.
>
> However, I can also see that it might not be out of line to have the
> class method lock the class such that the class itself can't be
> altered if another thread is in one of the class' methods. This,
> though, could be reasonably problematic, so I'm not sure it's a good
> idea. (Though altering the structure of the class when other code is
> using something of that class probably isn't the best thing either)
>
> It definitely is an issue, though.

>                                         Dan
jens
.sub _main
    newclass P5, "Foo"
    classname S0, P5
    assign S0, "Bar"

    find_type I1, "Foo"
    new P5, I1
    P5."myname"()
    
    end
.end

.namespace ["Foo"]

.sub myname method
    print "Foo\n"
.end

.namespace ["Bar"]

.sub myname method
    print "Bar\n"
.end

Reply via email to