Re: Techniques for thread communication
Re: Techniques for thread communication
- Subject: Re: Techniques for thread communication
- From: email@hidden (Peter Robinson)
- Date: Tue, 9 Sep 2003 11:13:05 +0100
Chris Purcell <email@hidden> wrote:
>
>> can one assume the assignment is atomic?
>
>
>
> I always have made that assumption, and therefore assumed that the
>
> following is totally thread safe:
>
>
>
> -(void) setIntResult: (int) val { intResult = val; }
>
> -(int) intResult { return intResult; }
>
>
>
> I'd like to know if that's wrong.
>
>
Only if intResult is not word-aligned: word-aligned reads and writes
>
are atomic on PPC and Intel alike.
That's good. AIUI int instance variables will normally be word-aligned.
But what about the same accessor pattern for the following instance
variables:
@interface SomeClass
{
short alignedShort, unalignedShort;
BOOL alignedBOOL, unalignedBOOL;
}
@end
I'm guessing (and hoping) that even though BOOLs and shorts have smaller
alignment, the same accessors are still thread safe in some sense.
Peter
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.