Re: non-blocking file writes
Re: non-blocking file writes
- Subject: Re: non-blocking file writes
- From: Devon E Bowen <email@hidden>
- Date: Tue, 8 Jul 2003 09:08:47 -0400 (EDT)
>
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.
That's half of the problem. The other half is being able to implement flow
control. For example, if I know that the file will block on a write, I
can implement flow control and tell my upstream source (network socket) to
stop sending me data. Otherwise, my process memory grows and grows as I
receive more data and need to hold on to it in this separate thread until
it gets written. Of course, I can implement some kind of artificial
threshold to simulate a block on write. Seems a bit odd, though. The other
solution suggested by email@hidden would have the same issues.
>
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.
That's usually true for local disk. But not for pathological conditions such
as an NFS host that goes missing during a reboot or something. I'm trying
to write a robust application. The UNIX select() call allows you to wait
for readability or writeability of any file descriptor. Seems strange to me
that this functionality gets lost in the Cocoa event loop. It's almost like
they are trying to prevent you from writing robust apps. 8-)
In any case, thanks for the help. Now I know I didn't miss something.
Devon
_______________________________________________
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.