From:                   Felix Geerinckx <[EMAIL PROTECTED]>

> on Tue, 09 Jul 2002 16:01:12 GMT, Jenda Krynicky wrote:
> 
> > So, your process gets notified if something happens in the
> > directory, it has to find out what was it by itself.
> 
> I wonder how one could avoid race conditions when using ChangeNotify.

You mean that you get notified of a change, start processing it and 
before you have the chance to start waiting again another change 
occures but you do not notice it at all? Well I don't really know.

I am using Win32::ChangeNotify a bit lately and I always use two 
threads. One ("watcher") only waits for the changes, prints a change 
message to the pipe and goes waiting again (so the chance that 
something happens while it's busy is slim) and the other thread 
("worker") reads the messages and other commands from the pipe and 
processes them. Actually if the worker thread starts scaning the 
directory for change after a tiny timeout (that is AFTER the watcher 
started waiting again) it will see even the change that was 
overlooked by watcher.

Or did you mean some other race condition?

Jenda
=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
                                        --- me


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to