• 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
Threading and NSPort retain count question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Threading and NSPort retain count question


  • Subject: Threading and NSPort retain count question
  • From: James Walker <email@hidden>
  • Date: Thu, 17 Sep 2009 17:39:26 -0700

In the "Threading Programming Guide", I'm trying to understand the discussion of communicating between threads using run loops and NSMachPort objects. (Before someone asks why I'm not looking at an easier way to pass messages between threads: I need to run on Tiger.) I'm confused about a retain count issue.

The setup code in the main thread (Listing 3-12) creates a port with [NSMachPort port]. This port is installed on the run loop (does the run loop retain the port?) and then passed to the worker thread. The worker thread function (Listing 3-14, +LaunchThreadWithPort:) takes that port and passes it to a method sendCheckinMessage of a newly created worker object. In sendCheckinMessage (Listing 3-15), the worker object retains the port, and uses it as a send port for a message. Now here's the part that confuses me: When control returns to Listing 3-14, the port gets released. Why? This class method didn't retain or create the port, so it shouldn't be releasing it, no?

--
  James W. Walker, Innoventive Software LLC
  <http://www.frameforge3d.com/>
_______________________________________________

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


  • Prev by Date: Re: Bindings and C arrays
  • Next by Date: Re: [myNSWindow setDocumentEdited:dirtyB] fail ??
  • Previous by thread: Re: Bindings and C arrays
  • Next by thread: Finding user's Music folder (and others)?
  • Index(es):
    • Date
    • Thread