Re: Notification redundancy
Re: Notification redundancy
- Subject: Re: Notification redundancy
- From: Ben Dougall <email@hidden>
- Date: Thu, 29 Jan 2004 15:40:09 +0000
On Thursday, January 29, 2004, at 01:25 pm, Allan Odgaard wrote:
On 28. Jan 2004, at 16:09, Erez Anzel wrote:
I have enjoyed using the notification system built into Cocoa. But
the standard approach may not be the wisest in my situation, where I
may have tens of thousands of objects sending notifications, and
multiple observers.
You may reduce it by using NSIndexSet -- but that would be more or
less the same as letting the action method send the notify.
In a case like this, it's more efficient for the action method to
post the notification, instead of each object. I could make a
decision at runtime as to whether the action posts the notification,
or each object, depending upon how many objects are involved. But
this starts to get messy; I have many different actions, many object
types, and many "set" methods for each.
Any wisdom on this issue?
You could let the objects add info about what they did to their
container and let the container send the notify, then, if anybody
wants to know exactly what happend, they would query the sender of the
notification.
But do all these 50,000 objects really need to be NSObject subclasses?
i.e. do they need any of the advantages that comes with being an
object (run-time polymorph method invocation, inheritance etc.), or
are they just simple points, to which you have added some action
methods (which could just as well be "global" functions)?
50,000 notification is 50,000 notifications. if all the objects really
need to be notified, which i guess they do, otherwise you wouldn't be
asking the question, then you're going to have to make 50,000
notifications. i don't think there's any getting away from that.
if making one notification 50,000 times, in a single go that is,
reaches some kind of limit/problem, then you could split up the
notifications, to get round that limit/problem, and achieve a kind of
tree notification structure - the root node notifies its children, who
notify their children etc until all 50,000 objects have been notified -
that way you're not making a single notification 50,000 times in one go
-- but you're still making 50,000 notifications.
does making 50,000 notifications in one go cause a problem? if so,
split 'em up, if not, don't. just a thought.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.