[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Setter Gettor method style
From: |
Nicola Pero |
Subject: |
Re: Setter Gettor method style |
Date: |
Mon, 5 Aug 2002 13:01:04 +0100 (BST) |
> True, you don't get it for free, you need to use locks. However,
> setters/getters like this would be safe:
>
> -(void) setFoo: (NSString *)newfoo
> {
> [foo_lock lock];
> ASSIGN(foo,newfoo);
> [foo_lock unlock];
> }
>
> -(NSString *) foo
> {
> NSString *retval;
> [foo_lock lock];
> retval=[[foo retain] autorelease];
> [foo_lock unlock];
> return retval;
> }
>
> To make a class thread-safe by itself, you have to retain and
> autorelease it inside the lock, so you need to do it before returning
> it. If you just return the value without doing the retain/autorelease,
> you can't get thread safety inside the class; the users would be forced
> to handle it themselves.
Ok - now makes sense :-)
- Re: Setter Gettor method style, (continued)
- 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, 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 <=
- 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, 2002/08/14
- 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