[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Setter Gettor method style
From: |
Christian Edward Gruber |
Subject: |
Re: Setter Gettor method style |
Date: |
Wed, 14 Aug 2002 07:15:48 -0400 |
----- Original Message -----
From: "Pascal Bourguignon" <pjb@informatimago.com>
> >
> > - (void) setTitle: (NSString *)newTitle {
> > [title autorelease];
>
> Here, there is not advantage to wait before releasing title. It's
> owned by the object, it can be released directly. If anybody has been
> interested in title it will have retained it long ago. Since title is
> overwritten immediately, it cannot be retrieved after this statement,
> so you can as well use release.
>
Unfortunately untrue. It is possible, and in a highly multi-processing box,
it is quite feasible that one thread will release the object, which will
release its title, before the calling object's can finish using title. Even
if someone goes:
id blah = [[[foo title] retain] autorelease]; there's a race-condition setup
there. It's not likely to fail, but it may fail. If your code is
multithreaded, then option number 2 is preferable.
> >
> > - (NSString *) title {
> > return [[title retain] autorelease];
>
> This is strictly equivalent to { return title; }
>
No, this is not true if you are in a truly multithreading environment.
regards,
Christian.
- Re: Setter Gettor method style, (continued)
- Re: Setter Gettor method style, Pascal Bourguignon, 2002/08/04
- Re: Setter Gettor method style, Pascal Bourguignon, 2002/08/04
- Re: Setter Gettor method style, Alexander Malmberg, 2002/08/04
- Re: Setter Gettor method style, Pascal Bourguignon, 2002/08/04
- Re: Setter Gettor method style, Alexander Malmberg, 2002/08/04
- Re: Setter Gettor method style, Nicola Pero, 2002/08/05
- Re: Setter Gettor method style, Alexander Malmberg, 2002/08/05
- Re: Setter Gettor method style, Nicola Pero, 2002/08/05
- Re: Setter Gettor discussion got to a halt, Martin Häcker, 2002/08/05
- Thread xxx : tossing reply message zzz, David Dicanot, 2002/08/06
- Re: Setter Gettor method style,
Christian Edward Gruber <=
- Re: Setter Gettor method style, Pascal Bourguignon, 2002/08/14
- Re: Setter Gettor method style, Philippe C . D . Robert, 2002/08/14
- Re: Setter Gettor method style, Christian Edward Gruber, 2002/08/14
Re: Setter Gettor method style, Nicola Pero, 2002/08/06
- Re: Setter Gettor method style, Martin Häcker, 2002/08/06
- Re: Setter Gettor method style, Nicola Pero, 2002/08/06
- GNUstep.h (was: Re: Setter Gettor method style), Lars Sonchocky-Helldorf, 2002/08/06
- Re: GNUstep.h (was: Re: Setter Gettor method style), Martin Häcker, 2002/08/06
- Re: GNUstep.h (was: Re: Setter Gettor method style), Sir Raorn, 2002/08/07
- Re: GNUstep.h (was: Re: Setter Gettor method style), Nicola Pero, 2002/08/07