Re: non-blocking file writes
Re: non-blocking file writes
- Subject: Re: non-blocking file writes
- From: Sherm Pendley <email@hidden>
- Date: Mon, 7 Jul 2003 19:58:16 -0400
On Monday, July 7, 2003, at 10:40 AM, Devon E Bowen wrote:
I'm a UNIX guy but with little Cocoa experience. 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.
Yep, you're right - NSFileHandle doesn't do that. It seems to me like a
strange omission. ;-(
As an alternative, you could create an NSMutableData object with
+dataWithContentsOfMappedFile: to use memory-mapped file IO. It's
basically an object-oriented wrapper around mmap() and friends, if
you're familiar with those. That way you'd just need to store your data
in memory, and the virtual memory system would write it out to disk as
needed.
sherm--
The highest sounds are hardest to hear.
Going forward is a way to retreat.
Great talent shows itself late in life.
Even a perfect program still has bugs.
-- The Tao of Programming
_______________________________________________
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.