• 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: NSRunLoop, processes and distributed objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSRunLoop, processes and distributed objects


  • Subject: Re: NSRunLoop, processes and distributed objects
  • From: Kaelin Colclasure <email@hidden>
  • Date: Thu, 24 Nov 2005 22:47:37 -0800

On Nov 24, 2005, at 9:10 AM, Felix Schwarz wrote:

Hi,

I'm having a problem with an NSRunLoop that does not exit. It includes the use of processes and distributed objects.

But first things first. My application launches a new process via NSTask, that then vends an object. The application finds that object, makes use of it, etc. However, when my application stops using the NSTask and even invalidates the NSConnection receive and send ports at the core of the distributed object used here, the runloop does not exit. It does not even exit if, in the seperate process, it is told to runUntilDate.

In the "Multithreading Programming Topics" part of the Cocoa docs, I found this:

-- cut --
Exiting a Thread’s Run Loop

When you execute a run loop, the thread enters a permanent loop, during which it processes events associated with the attached input sources and timers. If you want to terminate a thread once it has entered its run loop, there are several ways to do it. The most graceful way to exit is to remove all timers and input sources from the run loop. Without any event sources, the run loop exits naturally, letting your thread entry point function end normally. This is the preferred way for Cocoa threads to exit as it gives them a chance to delete their autorelease pools.

..

-- cut --

This was indeed the preferred way at one time -- but these days the problem with it is that many of the supporting frameworks register their own runloop sources to provision the services they provide. In general you have no control over when these sources are registered, and no way to invalidate them.


If you are certain that your application isn't depending on any of those "hidden" sources, you can run your runloop in a "private" runloop mode. Your private mode will contain only the sources you register, and you'll find then that invalidating those sources causes the runloop to exit as advertised.

On the other hand, it's usually simpler to write your own loop that calls -runMode:beforeDate: with your own loop termination condition.

-- Kaelin

_______________________________________________
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


References: 
 >NSRunLoop, processes and distributed objects (From: Felix Schwarz <email@hidden>)

  • Prev by Date: CoreData, adding & removing objects via NSArrayController
  • Next by Date: Re: QuickLiteRow and NSTableView problems
  • Previous by thread: NSRunLoop, processes and distributed objects
  • Next by thread: transparent window and transparent button problems
  • Index(es):
    • Date
    • Thread