discuss-gnustep
[Top][All Lists]
Advanced

[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 12:36:58 +0100 (BST)

> > The  rule that  says that  you  must retain  the objects  you need  is
> > failproof in all cases.
> 
> No. Obscure cases involving multiple threads could be constructed where
> [[foo retain] autorelease] worked properly but retaining it after it's
> been returned doesn't.

I don't see your point.  If you use multiple threads, unless you have a
lock, your getter/setter methods are not thread-safe (and so are liable to
crash at any moment) no matter if you retain foo before or after it is
returned.  Another thread can always be scheduled in such a perverse way
as to release foo after you've got its pointer, but before your retain
method implementation is executed - no matter where you do it, if in the
caller or in the getter.

I think multiple threads using getter/setter methods are outside the scope
of the discussion, since if you have multiple threads using getter/setter
methods concurrently, you need special care (a lock at the appropriate
level) in all cases, of which I don't see any mention in this dicussion.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]