• 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: non-blocking file writes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: non-blocking file writes


  • Subject: Re: non-blocking file writes
  • From: Cameron Hayne <email@hidden>
  • Date: Mon, 07 Jul 2003 18:16:26 -0400

On 7/7/03 10:40 AM, "Devon E Bowen" <email@hidden> wrote:

> I'm looking for a way
> to read and write data (ints, chars, etc) to a file. Sounds simple
> enough but I want to do it in a way that guarantees non-blocking I/O.
> I poked around through the docs and ran across NSFileHandle which seems
> to support methods for non-blocking reads (readInBackgroundAndNotify)
> but not for writes.
>
> So the question is... is there a better way to do this? Maybe another
> class I should be looking at? It seems like this is a pretty basic
> thing to want to do, no? Or do Cocoa programmers usually assume that
> writes will always work quickly enough to not worry about it? That would
> seem like bad coding style to me. Personally, I would prefer never to
> see that little beach ball spinning in my code.

If I understand you correctly, what you are asking is how do I write to a
file without making the user wait for the write to finish? I think the only
answer is to do the file writing in a separate thread.
But you are correct that few people would go to that trouble - since in most
cases file writes are finished in fractions of a second.
(The main reason for using readInBackgroundAndNotify is when the data comes
in over an extended period of time from some external source like a script.)

--
Cameron Hayne (email@hidden)
Hayne of Tintagel
_______________________________________________
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.

References: 
 >non-blocking file writes (From: Devon E Bowen <email@hidden>)

  • Prev by Date: selection area when dragging mouse
  • Next by Date: accessing files larger than 2GB
  • Previous by thread: non-blocking file writes
  • Next by thread: Re: non-blocking file writes
  • Index(es):
    • Date
    • Thread