-[NSFileHandle waitForDataInBackgroundAndNotify] versus CFFileDescriptor
-[NSFileHandle waitForDataInBackgroundAndNotify] versus CFFileDescriptor
- Subject: -[NSFileHandle waitForDataInBackgroundAndNotify] versus CFFileDescriptor
- From: "Hamish Allan" <email@hidden>
- Date: Mon, 11 Feb 2008 00:25:35 +0000
Hi,
I need to monitor the stdout of an NSTask within a run loop. The docs
for - [NSFileHandle waitForDataInBackgroundAndNotify] say:
"When the data becomes available, the thread notifies all observers
with NSFileHandleDataAvailableNotification. After the notification has
been posted, the thread is terminated."
It seems rather inefficient to me to create and destroy a thread for
every flush of data. However, the docs for CFFileDescriptor say:
"You use CFFileDescriptor to monitor file descriptors for read and
write activity via CFRunLoop using callbacks. Each call back is
one-shot, and must be re-enabled if you want to get another one."
In other words, this doesn't sound much better (c.f. CFSocket
RunLoopSources, which you don't have to re-enable).
Is there any technical reason why both of these mechanisms are
designed this way, that I would discover if I tried to implement my
own reader thread?
Thanks,
Hamish
_______________________________________________
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