• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How To Design A Queue of Messages?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How To Design A Queue of Messages?


  • Subject: Re: How To Design A Queue of Messages?
  • From: j o a r <email@hidden>
  • Date: Sun, 11 Sep 2005 01:27:45 +0200


On 10 sep 2005, at 23.46, Andreas Mayer wrote:

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.

My point is that in most cases (certainly not all, but probably most) I doubt that you still want to send the message to that object if the message queue is the only one retaining it.
I was not worried about memory leaks, but rather the conceptual problem with allowing the message queue to assume "ownership" of it's targets.


Most objects have some sort of owner or controller. I would not mind so much that you retain the enqueued objects if you allow the owner not only the ability to enqueue, but also to dequeue an object at any time.
That said, if you have that ability, then there really is little use in retaining the enqueued objects in the first place.


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.)

I was not concerned about the possibility for leaks.

j o a r


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

  • Follow-Ups:
    • Re: How To Design A Queue of Messages?
      • From: Andreas Mayer <email@hidden>
References: 
 >How To Design A Queue of Messages? (From: Jerry Krinock <email@hidden>)
 >Re: How To Design A Queue of Messages? (From: Andreas Mayer <email@hidden>)
 >Re: How To Design A Queue of Messages? (From: Frode <email@hidden>)
 >Re: How To Design A Queue of Messages? (From: Andreas Mayer <email@hidden>)
 >Re: How To Design A Queue of Messages? (From: Frode <email@hidden>)
 >Re: How To Design A Queue of Messages? (From: j o a r <email@hidden>)
 >Re: How To Design A Queue of Messages? (From: Andreas Mayer <email@hidden>)

  • Prev by Date: Re: How To Design A Queue of Messages?
  • Next by Date: _newFirstResponderAfterResigining
  • Previous by thread: Re: How To Design A Queue of Messages?
  • Next by thread: Re: How To Design A Queue of Messages?
  • Index(es):
    • Date
    • Thread