• 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: performSelectorOnMainThread and other thread notifications
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: performSelectorOnMainThread and other thread notifications


  • Subject: Re: performSelectorOnMainThread and other thread notifications
  • From: Glen Low <email@hidden>
  • Date: Fri, 13 Feb 2004 07:58:12 +0800

The secondary threads cannot be running an NSRunLoop since I don't want to poll the kqueue, I want to block on it waiting for a file system change (hmm.. unless NSRunLoops support such things). But if I block waiting for a change, how will the main thread interrupt it, say when a document is closed and no longer needs to be monitored?

NSRunLoops don't really poll, it blocks waiting on an event to come in from one of its registered event sources and then check the sources as needed. In other words it doesn't spin in a loop wasting CPU time. Note almost all apps in Mac OS X have a run loop (NSRunLoop/CFRunLoop) for its core event loop.

If you can get your kqueue attached as a source for the run loop you could also attach a source (say an NSPort) that can be used to talk with your secondary thread (while it is running the run loop). I need to read up on kqueues myself so I cannot help you much and don't want to go to far an mislead ya... so take what I am saying with a grain of salt.

I realize NSRunLoops likely do not poll, although I would have to use them in a polling fashion if I can't attach a kqueue as an event source. As I understand it, NSPort is an abstraction of a Mach port? Can I get some equivalence between a Mach port and a UNIX/BSD file descriptor?

Originally I thought of opening an NSPipe from the main thread, and passing the UNIX/BSD file descriptor for the read end to the kqueue thread. Now kqueues can monitor file descriptors, so I could send messages down the pipe. However Apple docs seem to say NSPipe is *not* threadsafe. *sigh*...

"man kqueue" is pretty informative.

Cheers, Glen Low


---
pixelglow software | simply brilliant stuff
www.pixelglow.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >performSelectorOnMainThread and other thread notifications (From: Glen Low <email@hidden>)
 >Re: performSelectorOnMainThread and other thread notifications (From: Shawn Erickson <email@hidden>)
 >Re: performSelectorOnMainThread and other thread notifications (From: Glen Low <email@hidden>)
 >Re: performSelectorOnMainThread and other thread notifications (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Re: Making the correct button the default button?
  • Next by Date: Re: update preference problem
  • Previous by thread: Re: performSelectorOnMainThread and other thread notifications
  • Next by thread: Re: performSelectorOnMainThread and other thread notifications
  • Index(es):
    • Date
    • Thread