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 protected])

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

This email sent to [email protected]

Reply via email to