• 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: Mon, 16 Feb 2004 23:26:41 +0800

Shawn, All:

I haven't decided whether to have one thread per file or one thread for all files.

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.

OK, kqueue seems more and more like a good candidate. Looking at sys/event.h it appears to handle EVFILT_MACHPORT and EVFILT_FS, which isn't documented anywhere? -- any clues what these two do, anyone, especially Apple employees in the know!? -- but if it can be interrupted with a Mach port, I'll have a threadsafe way of notifying my kqueue'd thread. Last question then is: is kqueue itself threadsafe? (I know that BSD kqueue is fairly ignorant of threads, but I'm hoping it can be run from a different thread than the main thread, and not cause subtle, irritating errors...)


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: Cant't use UTF-8 source files. False string interpretation.
  • Next by Date: Re: NSEnumerator doesn't support NSCopying - why?
  • Previous by thread: Re: performSelectorOnMainThread and other thread notifications
  • Next by thread: Fwd: (Solved) prefs stopped saving.
  • Index(es):
    • Date
    • Thread