• 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: What happens to the user dictionary when coalescing notifications in NSNotificationQueue?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What happens to the user dictionary when coalescing notifications in NSNotificationQueue?


  • Subject: Re: What happens to the user dictionary when coalescing notifications in NSNotificationQueue?
  • From: Cem <email@hidden>
  • Date: Thu, 25 Sep 2008 19:22:46 -0400

I've got a class that acts like a super-lightweight server within my program. It listens for incoming packets of information, decodes them, and then tells the rest of my code that something changed. So far, this sounds like a job for NSNotificationCenter, except that I'm getting the packets by UDP, and don't want to tell all the listeners about every single update that happens; it would be better to coalesce them into one notification and notify them when the run loop is idle. OK, so this sounds perfect for NSNotificationQueue with (NSNoticationCoalescingOnName| NSNotificationCoalescingOnSender) as the options. The problem is that I want to send all the data along in the user dictionary. How is that coalesced? Note that I want ALL the data I'm putting in the dictionary, not just the last user dict.

You could create a method on your server class that returns the all the data as one NSData object. So, create a mutable data object in your server object and
every time you get a UDP packet, add that to the data and then post a notification. When the notification gets received, the notified object messages your server
object and retrieves all the data that way. Just make sure that the retrieve call is properly synchronized or that everything is running on the same thread
and you should have no problems. That's the way I would do it, anyway.

The problem is that each packet is an individual chunk of data that I store in a data structure. I don't want to tell listeners that something changed, because there is going to be a lot of stuff; I want to be able to tell them 'here are the things that changed'. I could probably maintain a cache, and have all registered listeners tell me when they've received a message (so I can merge the cache back into the database), but that gets messier than I'd like.


Basically, if I know what is supported in coalescing, then I can work with it, if necessary, working around it. I just need to know that things won't suddenly change one day. That is why I'm trying to figure out the precise meaning of coalesce when it comes to the user dictionaries.

Thanks,
Cem Karan
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Adding external library in cocoa app
  • Next by Date: Re: Autostart item in user profile.
  • Previous by thread: Re: Autostart item in user profile.
  • Next by thread: popup button wierdness
  • Index(es):
    • Date
    • Thread