• 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: Notifications and timing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Notifications and timing


  • Subject: Re: Notifications and timing
  • From: Randall Meadows <email@hidden>
  • Date: Thu, 12 Mar 2009 11:58:13 -0600

On Mar 12, 2009, at 11:46 AM, McLaughlin, Michael P. wrote:

I have a "global" gFlags variable (unsigned long long) and several objects
that need a pointer to it. I fill one such pointer, and reinit gFlags, via
the following code:


if (flags == nil) {
flagPtr *flgH = &flags;
NSData *flgsDatum =
[[NSData alloc] initWithBytesNoCopy:flgH length:sizeof(flgH)
freeWhenDone:NO];
[[NSNotificationCenter defaultCenter] postNotificationName:@"fetchFlags"
object:flgsDatum];
*flags = (WORKING | (*flags & LOGFILE));
}


This code appears to work successfully. My question is whether the
notification is responded to in a synchronous manner so that the pointer is
guaranteed to be filled in by the time


  *flags = (WORKING | (*flags & LOGFILE));

is executed.


NSNotificationCenter Class Reference sez:

"A notification center delivers notifications to observers synchronously. In other words, thepostNotification: methods do not return until all observers have received and processed the notification. To send notifications asynchronously useNSNotificationQueue. In a multithreaded application, notifications are always delivered in the thread in which the notification was posted, which may not be the same thread in which an observer registered itself."
_______________________________________________


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


References: 
 >Notifications and timing (From: "McLaughlin, Michael P." <email@hidden>)

  • Prev by Date: Re: Performance problem with GC enabled
  • Next by Date: Re: Synthesized instance variables
  • Previous by thread: Notifications and timing
  • Next by thread: Multiple Images into one UIView
  • Index(es):
    • Date
    • Thread