• 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: Multithreading and Mach ports
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multithreading and Mach ports


  • Subject: Re: Multithreading and Mach ports
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Tue, 9 Dec 2008 21:56:41 +0100


Le 9 déc. 08 à 21:36, John Love a écrit :

Reference:

http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/chapter_6_section_5.html#/ /apple_ref/doc/uid/10000057i-CH16-SW7

I've got several questions since I'm just starting to investigate Mach Ports.

1) Why is +LaunchThreadWithPort: so designated, ie, a class method. It seems to me that as far as the specific code listings presented, a class method is not required? For example, [workerObj sendCheckinMessage:distantPort] could be replaced with [self sendCheckinMessage:distantPort] if LaunchThreadWithPort would be changed to an instance method.

2) Maybe the real question #1 is: What exactly is the object in the background thread, named workerObj ??

An arbitrary object that perform some long works that should be execute in a background thread. "Worker" is a very common term in multithreading programming.



3) I've saved my most general question to last, at least for this trip: currently when I enter my method to start up my background thread or threads, I simply call (several times if I have multiple threads:


[NSThread detachNewThreadSelector:@selector(bgCalcThread:) toTarget:self withObject:nil]

If I have multiple background threads, I can use a NSMutableDictionary with multiple keys for inter-thread communication


I think I miss something in the NSDictionary reference. I though it was not thread safe, and I never saw any reference to synchronisation or communication methods. What do you mean by "using dictionary for inter thread communication" ?


So, what do Mach Ports give me that the above doesn't?

A channel to send arbitrary message to another thread (of course, it can also be done using performOnThread methods).



_______________________________________________

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: 
 >Multithreading and Mach ports (From: John Love <email@hidden>)

  • Prev by Date: Re: Quote in path name
  • Next by Date: Setting company checkbox programatically in an AddressBook
  • Previous by thread: Multithreading and Mach ports
  • Next by thread: Re: Multithreading and Mach ports
  • Index(es):
    • Date
    • Thread