• 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: NSNotificationCenter does the doc lie to us ??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNotificationCenter does the doc lie to us ??


  • Subject: Re: NSNotificationCenter does the doc lie to us ??
  • From: Aurélien Hugelé <email@hidden>
  • Date: Fri, 11 Mar 2005 08:39:28 +0100

Yes i'm currently using something like NSLog( @"My thread is: %x" , [ NSThread currentThread ] ) ...
i'll try your code and report


thanks :)

Le 11 mars 05, à 02:37, Mike R. Manzano a écrit :

How are you getting the current thread? If you are doing something like this:

NSLog( @"My thread is:  %x" , [ NSThread currentThread ] ) ;

it won't work, since you're outputting the address of the NSThread object, not the actual thread's ID. I don't think that Cocoa necessarily guarantees that the NSThread object returned by currentThread will always be the same for any given thread ID.

Instead do this:

import <pthread.h>

NSLog( @"My thread is:  %x" , pthread_self() ) ;

This should return the actual thread ID of the thread underlying NSThread.

	~ Mike

On Mar 10, 2005, at 5:42 AM, Aurélien Hugelé wrote:

Hi list !

Reading the documentation about NSNotificationCenter and notification posting, you can read this :
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.

the keyword here is **always**

i post a notification is the *main thread*, and its handler is executed in another thread :

2005-03-10 14:32:30.788 OD4MailPod Helper[2957] OD4MailPodHelperController: scanConnectedIpod: going to post "iPodDidConnect" Notification !
2005-03-10 14:32:30.788 OD4MailPod Helper[2957] OD4MailPodHelperController: scanConnectedIpod: current Thread = 0x00312AB0
2005-03-10 14:32:30.788 OD4MailPod Helper[2957] OD4MailPodHelperController: scanConnectedIpod: posted "iPodDidConnect" Notification !


2005-03-10 14:32:30.963 OD4MailPod Helper[2957] ODMPHAutonomousServer: iPodDidConnect: current Thread = 0x00342E70

as you can see the notification handler is not executed in the thread the notification was posted !?

can anybody explain me what happens ?
(Note that i don't want to know how to post in specific thread, but to know why do i not see what should be expected from the doc ;-) )


thanks
 _______________________________________________
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


_______________________________________________ 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: NSNotificationCenter does the doc lie to us ??
      • From: Aurélien Hugelé <email@hidden>
References: 
 >NSNotificationCenter does the doc lie to us ?? (From: Aurélien Hugelé <email@hidden>)
 >Re: NSNotificationCenter does the doc lie to us ?? (From: "Mike R. Manzano" <email@hidden>)

  • Prev by Date: NSFileHandleConnectionAcceptedNotification
  • Next by Date: Download a file
  • Previous by thread: Re: NSNotificationCenter does the doc lie to us ??
  • Next by thread: Re: NSNotificationCenter does the doc lie to us ??
  • Index(es):
    • Date
    • Thread