• Fabrice Popineau's avatar
    Improve w32notify notifications · 326fff41
    Fabrice Popineau authored
    * src/w32notify.c (DIRWATCH_BUFFER_SIZE): New macro.
    (struct notification): 'terminate' is now a HANDLE.
    (send_notifications): Argument is now a pointer to a
    notification.  Don't loop waiting for the notification to be
    acknowledged by the main thread; instead, just add the
    notification to the linked list of notifications waiting to be
    acknowledged.
    (watch_end): Don't close the directory handle.
    (watch_completion): Allocate a new notification structure to be
    added to the notifications set.  Call ReadDirectoryChangesW
    immediately after adding the new notification, and before sending
    a message to the main thread about them.
    (watch_worker): Don't loop calling ReadDirectoryChangesW; instead,
    call it just once -- it will be called again in watch_completion.
    Loop waiting for the main thread's indication to terminate.
    (start_watching): Create the event to be used to indicate to the
    worker thread that its should terminate.
    (remove_watch): Indicate to the worker thread that it should
    terminate.
    * src/w32term.c (queue_notifications): Loop over all the
    notifications in the linked list, processing all of them in one
    go.
    * src/w32inevt.c (handle_file_notifications): Loop over all the
    notifications in the linked list.
    * src/w32xfns.c (init_crit): Initialize the linked list of file
    notifications.
    (delete_crit): Free the linked list of file notifications,
    including any unprocessed notifications left in it.
    * src/w32term.h (struct notifications_se): New struct.
    
    * test/lisp/filenotify-tests.el (file-notify-test02-events)
    (file-notify-test05-dir-validity): Add read-event calls to
    facilitate event recognition by the main thread in batch mode.
    326fff41
w32inevt.c 23.6 KB