Asynchronous IO lags at close

2010-01-19 Thread Justin Delegard
I am writing a screen saver that forks a process and reads its stdout 
chunk by chunk.  Since I didn't want it to block on reads, I tried to 
find the non-blocking IO parts of Cocoa.  I found Cocoa's 
NSNotificationCenter, and the associated methods with the NSFileHandle 
class, and that seemed to fit the bill.  It works fine *except* it 
doesn't notice the closes.


My guess is it has something to do with the main loop being blocked 
after the close.  It notices the last chunk of data and the close at the 
same time, but then it never notices after my 
last waitForDataInBackgroundAndNotify call.  I don't want the routine 
reading the data to be blocked, but I want to know in a timely way if 
the file handle is closed.  How do I do that?  What should I be doing?


Justin

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com


Screen saver using Asynchronous IO lags at close

2010-01-17 Thread Justin Delegard
I am writing a screen saver that forks a process and reads its stdout chunk by 
chunk.  Since I didn't want it to block on reads, I tried to find the 
non-blocking IO parts of Cocoa.  I found Cocoa's NSNotificationCenter, and the 
associated methods with the NSFileHandle class, and that seemed to fit the 
bill.  It works fine *except* it doesn't notice the closes.

My guess is it has something to do with the main loop being blocked after the 
close.  It notices the last chunk of data and the close at the same time, but 
then it never notices after my last waitForDataInBackgroundAndNotify call.  I 
don't want the routine reading the data to be blocked, but I want to know in a 
timely way if the file handle is closed.  How do I do that?  What should I be 
doing?

Justin

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com