Re: NSNotificationQueue Question

2015-05-20 Thread Kyle Sluder
On Wed, May 20, 2015, at 12:59 PM, Jens Alfke wrote:
> 
> > On May 20, 2015, at 10:18 AM, Richard Charles  wrote:
> > 
> > This works but the problem is that there are undesirable side effects to 
> > running the runloop once when this call is made.
> 
> Yup. Manually spinning the runloop in any non-custom mode is generally a
> bad idea.

I would revise this a bit… spinning the runloop in Default mode is
generally not advisable. Spinning in event tracking mode is far more
common. Spinning in a custom mode is definitely only for those who
really know what they're doing… if you start calling out to other code,
that code might be very confused when its timers don't fire.

--Kyle Sluder

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSNotificationQueue Question

2015-05-20 Thread Jonathan Taylor
> I have a bit of code that posts notifications to coalescing notification 
> queue.
> [...]
> In another place I need to force the notification queue to issue a did change 
> notification.
> 
> This works but the problem is that there are undesirable side effects to 
> running the runloop once when this call is made.
> What I would like to do is to run the runloop once but only cause the 
> notification queue to post this notification but not do other things.

Is that definitely the way you need to do it, or would you be happy with 
pulling the notifications from the queue using dequeueNotificationsMatching, 
and then reposting with NSPostASAP or NSPostNow?
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSNotificationQueue Question

2015-05-20 Thread Jens Alfke

> On May 20, 2015, at 10:18 AM, Richard Charles  wrote:
> 
> This works but the problem is that there are undesirable side effects to 
> running the runloop once when this call is made.

Yup. Manually spinning the runloop in any non-custom mode is generally a bad 
idea.

> What I would like to do is to run the runloop once but only cause the 
> notification queue to post this notification but not do other things.

I don’t think that’s possible. NSNotificationQueue is convenient but limited; I 
suggest rolling your own equivalent using a timer or delayed-perform.

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSNotificationQueue Question

2015-05-20 Thread Richard Charles
I have a bit of code that posts notifications to coalescing notification queue.

// Post did change notifications to a coalescing notification queue.
// Notifications are coalesced that match both the notification name and
// object. The notification is posted at the end of the current notification
// callout or timer.
NSNotification *notification =
[NSNotification notificationWithName:MyRelationshipDidChangeNotification
  object:object
userInfo:change];
[[NSNotificationQueue defaultQueue] enqueueNotification:notification
   postingStyle:NSPostASAP];

In another place I need to force the notification queue to issue a did change 
notification.

// Force notification queue to issue notification.
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:nil];

This works but the problem is that there are undesirable side effects to 
running the runloop once when this call is made.

What I would like to do is to run the runloop once but only cause the 
notification queue to post this notification but not do other things.

Anyone know how to do this?

--Richard Charles


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com