Re: File Detection
Re: File Detection
- Subject: Re: File Detection
- From: Mason Mark <email@hidden>
- Date: Mon, 28 Apr 2003 11:16:13 -0700
--On Monday, April 28, 2003 8:13 AM -0400 Jim Correia
<email@hidden> wrote:
On Monday, April 28, 2003, at 07:00 AM, Nathan Day wrote:
Someone has released some code that does this and they basically just
do what you suggest periodically checking for any change. If you are
not to concerned with knowing immediately about any change, polling
every 5 secs or even every 5 min, then this is not much for cpu
running at 1 GHz.
Playing devil's advocate...
Polling can have a big impact even on a 1 GHz machine. Imagine the
situation where the machine has limited RAM and a large working set. Your
application is paged out. Your application needs to be paged in (or stays
paged in because its pages are always hot if you poll frequently) to do
its work, then is paged out before the next poll cycle because a lot is
going on on a machine with limited resources. (And if you've got beefy
development hardware and aren't cognizant of the issue, you might not
even realize you are having this impact on a machine with lesser
resources, or similar resources with a larger typical working set.)
Playing whining developer...
There is no feasible solution to this problem other than polling.
It's been pretty widely discussed on the lists that NSWorkspace's
notifications don't work for this.
Carbon has FNNotify() and friends (which allow sending and receiving
notifications about filesystem changes), but these only work if the
application moving the files supports them. Spectacularly, even the Finder
doesn't reliably use this mechanism (or at least didn't until recently).
I've encountered this situation before, but not where it is
mission-critical to note file changes. So we've made sure our app uses
FNNotify() (and we require 10.2.5 where the Finder seems to notify more
reliably).
But in our app, it is not a matter of life or death, it is just a nuisance
if the changes aren't noticed.
If you really have to notice, then you really have to poll (which, agreed,
is highly undesirable). You could perhaps use FNNotify and friends, and
then poll less frequently...
--
Mason Mark
Five Speed Software, Inc.
_______________________________________________
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.