Re: How To Design A Queue of Messages?
Re: How To Design A Queue of Messages?
- Subject: Re: How To Design A Queue of Messages?
- From: Andreas Mayer <email@hidden>
- Date: Sat, 10 Sep 2005 23:46:56 +0200
Am 10.09.2005 um 22:46 Uhr schrieb j o a r:
I personally wouldn't retain my targets in such an implementation,
For this specific problem I disagree.
The OP wanted to queue messages to send them some time later. In case
you don't retain the target here, it might get deallocated before the
message is sent - which will not only lead to an exception, but will
leave the intended work undone.
As long as it is certain that the queue will be emptied, the target
will eventually be released an so there's no risk of a memory leak.
(You shouldn't rely on a specific object being deallocated at a
specific time anyway, so there's no harm done by possibly delaying
the deallocation of the target.)
(Also note, that in my sample code there are no explicit retain/
release messages. I'm using a dictionary to hold the target;
dictionaries do retain stored objects automatically and release them
as soon as they are removed. I just *love* Cocoa memory management. :))
Andreas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden