• 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: Beachball on Lengthy Task
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Beachball on Lengthy Task


  • Subject: Re: Beachball on Lengthy Task
  • From: Pierce Freeman <email@hidden>
  • Date: Sun, 05 Apr 2009 11:28:49 -0700
  • Thread-topic: Beachball on Lengthy Task

David:

Thanks for your help, this seems like a class that will be perfect for what
I am doing!  Just a few questions:

1. Is there any concern of thread safety using this class?
2. How can I pass NSFileHandle the file URL of my files?
3. How could I create a method that will take the contents of the file and
do something with them?

Sorry about the big questions. ;)


Sincerely,

Pierce Freeman


On 4/4/09 9:10 PM, "Dave Keck" <email@hidden> wrote:

>> Yeah, it really helped!  I am trying to get the contents of the files in a
>> certain directory, so I think that I could probably get away with using a
>> timer.
>
> In this case, the reason your task is taking several seconds to
> complete is most likely attributed to the sheer time it takes the read
> the contents of the files; that is, most of the time that it takes for
> the lengthy-task to complete isn't due to lots of
> computation-intensive stuff going on, but rather the age-old slow disk
> read. On the list of the 3 best times to use threads, reading large
> files from disk would perhaps be one of them...
>
> I probably should have asked for more information before forming my
> last post - for this case in particular, I would use NSFileHandle's
> asynchronous file reading mechanisms (which create separate threads
> for you, so you don't have to worry about it). Read about NSFileHandle
> in the docs, specifically, check out
> -readToEndOfFileInBackgroundAndNotify.
>
> At any rate, to get the contents of every file in a directory, I would
> iterate over the files in the directory, creating an NSFileHandle for
> each one, and call -readToEndOfFileInBackgroundAndNotify for each.
> Depending on how many files you're expecting, you may need to call
> -readToEndOfFileInBackgroundAndNotify on a small number of
> NSFileHandles, wait until those have finished reading, call it on the
> next group of NSFileHandles, etc.
>
> Note that while you may have escaped from using threads this time
> (directly, at least) that's not always going to be the case :).
> Threads are indispensable and with the number of cores chips are
> sporting these days, will only become more so...
>
> Good luck!
>
> David


_______________________________________________

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

  • Follow-Ups:
    • Re: Beachball on Lengthy Task
      • From: Dave Keck <email@hidden>
References: 
 >Re: Beachball on Lengthy Task (From: Dave Keck <email@hidden>)

  • Prev by Date: Re: Beachball on Lengthy Task
  • Next by Date: Re: Beachball on Lengthy Task
  • Previous by thread: Re: Beachball on Lengthy Task
  • Next by thread: Re: Beachball on Lengthy Task
  • Index(es):
    • Date
    • Thread