On 20/08/2010, at 2:37 PM, Ken Thomases wrote:

> On Aug 19, 2010, at 10:00 PM, Ron Fleckner wrote:
> 
>> I'm developing a stand alone text service for changing/fixing case.  For the 
>> simple cases of uppercasing and lowercasing I've simply used NSString's 
>> built in methods.  But to correct sentence case, where the original text may 
>> have lowercase letters following full stops (period in American?) I've been 
>> using an NSTask to run a perl script which lives in my app package.  That 
>> script also looks after other things such as a lone lowercase 'i' which 
>> should probably by 'I'.  It works very well until the input text is greater 
>> than 64KB at which point an alert will appear in the service-using process, 
>> TextEdit in my testing so far, saying either that the service didn't send 
>> back the expected text in time or that the service didn't respond.  After 
>> that, all the other services vended by my service are also cactus.
>> 
>> I'm not sure how or if I can get around this 64KB limit.  I've tried various 
>> things like breaking the text up into smaller pieces if it's over 64KB and 
>> feeding those bits to the task, but so far without success.
> 
> You're probably deadlocking on pipe communication.  You have to use the 
> asynchronous NSFileHandle methods to a) write only when there's room in the 
> task-input channel, and simultaneously b) read when there's data available 
> from the task-output channel.
> 
> If you try to write all of your task-input first, the channel will fill.  The 
> task will read some of it, produce output, then its output channel will fill. 
>  Your app is blocked trying to write the rest of the data, the task isn't 
> reading it because it's blocked trying to write its output, which your app 
> isn't reading yet.
> 
> The other approach is to use on-disk files rather than pipes to communicate 
> back and forth.
> 
> Regards,
> Ken
> 

Great food for thought.  Now I'll have a look at different ways of approaching 
this, including temporary on-disk files, with some idea of what's going on.  
Thanks for a very clear conceptual explanation.

Ron

_______________________________________________

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

Reply via email to