[Win32utils-devel] Some more win32-changenotify analysis

Heesob Park phasis at gmail.com
Thu Aug 9 11:44:05 EDT 2007


2007/8/9, Daniel Berger <djberg96 at gmail.com>:

> On 8/9/07, Heesob Park <phasis at gmail.com> wrote:
> >
> >
> >
> > 2007/8/9, Daniel Berger <djberg96 at gmail.com>:
> > > On 8/9/07, Heesob Park <phasis at gmail.com> wrote:
> > > > Hi,
> > > >
> > > >
> > > > 2007/8/9, Daniel Berger <djberg96 at gmail.com>:
> > > > > > On 8/9/07, Heesob Park <phasis at gmail.com> wrote:
> > > > >
> > > > > <snip>
> > > > >
> > > > > > > In my test with XP Home SP2 , it works fine.
> > > > > > > Do you modified both wait and get_file_aciton with my version?
> > > > >
> > > > > BTW, I committed the changes (with some extra error checking) into
> CVS
> > > > > so you can take a look.
> > > >
> > > >
> > > > Now I noticed some events ocurred between GetQueuedCompletionStatus
> and
> > > > ReadDirectoryChangesW might be missed. The faster CPU machine can
> detect
> > the
> > > > more events. And this version cannot detect the whole events.
> > >
> > > Anything we can do to improve it? I think we're still doing better
> > > than the current C version in any case. :)
> >
> >
> > In case of C version, I guess It could be improved by using thread. But
> in
> > case of pure Ruby version, I have no idea.
> > If someday Ruby support native windows thread, it would be much better.
>
> Would wrapping that section of code in a Ruby thread help at all? Or
> not really due to the nature of the code?


I have tried several Ruby threading, but it didn't help at all.
The basic idea is like this:

         arr = []
         Thread.new {
         while true
            bool = GetQueuedCompletionStatus(
               comp_port,
               qbytes,
               comp_key,
               @overlap,
               seconds
            )

            unless bool
              raise Error, get_last_error
            end

            break if comp_key.unpack('L').first == 0

            #yield get_file_action(fni) if block_given?
            arr.push(fni.dup)
            bool = ReadDirectoryChangesW(
               dir_handle,
               fni,
               fni.size,
               subtree,
               @filter,
               rbytes,
               @overlap,
               0
            )

            unless bool
               raise Error, get_last_error
            end
         end
         }
        while true
           while arr.length>0
             yield get_file_action(arr.pop) if block_given?
           end
           sleep 0.5
        end




> One other thing I've noticed is that it doesn't appear possible to
> Ctrl-C out of that code, even if I setup a separate sleeper thread in
> the main program. I have to kill it with the task manager. This is a
> minor issue, but I thought I'd mention it in case you had any ideas.


Or press Ctrl-C and delete some monitoring file :)

Regards,

Park Heesob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20070810/b4335f79/attachment-0001.html 


More information about the win32utils-devel mailing list