NSFileHandle difference Jaguar vs Panther?
NSFileHandle difference Jaguar vs Panther?
- Subject: NSFileHandle difference Jaguar vs Panther?
- From: Jirka Jirout <email@hidden>
- Date: Tue, 23 Mar 2004 19:22:45 +0100
I have the following code, that works fine in Jaguar (the method runs
in its own thread).
- (void) refreshData{
NSString *characterRead;
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
while (continueReading){
// get what's available in the device buffer
characterRead=[[NSString alloc] initWith
Data:[commPort
availableData] encoding:NSASCIIStringEncoding];
[lineBeingRead appendString: characterRead]; // append it to
the internal buffer
[characterRead release];
//bla bla bla
}
[pool release];
}
If the same app is run on Panther and there is no data on the input
(serial port), it generates really very high and continuous CPU load
(50% and more). Since it is used in my car, the extra heat generated by
the CPU is quite an issue (normally the CPU runs at about 44 :C, now it
is over 60) :-(
After some checking, it all seems to come down to -availableData method
of NSFileHandle. According to the documentation, it "blocks" if no data
is available. Since the method is running in a separate thread, just
blocking would not be a problem. But if the thread uses 50% of the CPU
just to wait for data... :-((
Is it possible the implementation of -availableData was significantly
changed between Jaguar and Panther? Will it help if I re-write the code
using -readInBackgroundAndNotify approach?
jj
_______________________________________________
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.