aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2012-12-10 14:38:49 +0200
committerEli Zaretskii2012-12-10 14:38:49 +0200
commitf282b9f7987fd7c2c8e323cc9f934ea53c05c3af (patch)
tree79a425d3460b8c39115f89ee4a4bc1e7988751e8
parent3907e630a71d48e693062b350571990d7ba08bbb (diff)
downloademacs-f282b9f7987fd7c2c8e323cc9f934ea53c05c3af.tar.gz
emacs-f282b9f7987fd7c2c8e323cc9f934ea53c05c3af.zip
Proof-read comments on w32notify.c. Adapt NEWS entry.
-rw-r--r--etc/NEWS3
-rw-r--r--src/w32notify.c35
2 files changed, 22 insertions, 16 deletions
diff --git a/etc/NEWS b/etc/NEWS
index f04dcea2bde..77e7e47b8a3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -136,7 +136,8 @@ spurious warnings about an unused var.
136** Support for filesystem notifications. 136** Support for filesystem notifications.
137Emacs now supports notifications of filesystem changes, such as 137Emacs now supports notifications of filesystem changes, such as
138creation, modification, and deletion of files. This requires the 138creation, modification, and deletion of files. This requires the
139'inotify' API on GNU/Linux systems. 139'inotify' API on GNU/Linux systems. On MS-Windows systems, this is
140supported for Windows XP and newer versions.
140 141
141** Face changes 142** Face changes
142 143
diff --git a/src/w32notify.c b/src/w32notify.c
index afa03498ff3..3095103484a 100644
--- a/src/w32notify.c
+++ b/src/w32notify.c
@@ -16,15 +16,18 @@ GNU General Public License for more details.
16You should have received a copy of the GNU General Public License 16You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19/* Design overview: 19/* Written by Eli Zaretskii <eliz@gnu.org>.
20
21 Design overview:
20 22
21 For each watch request, we launch a separate worker thread. The 23 For each watch request, we launch a separate worker thread. The
22 worker thread runs the watch_worker function, which issues an 24 worker thread runs the watch_worker function, which issues an
23 asynchronous call to ReadDirectoryChangesW, and then waits for that 25 asynchronous call to ReadDirectoryChangesW, and then waits in
24 call to complete in SleepEx. Waiting in SleepEx puts the thread in 26 SleepEx for that call to complete. Waiting in SleepEx puts the
25 an alertable state, so it wakes up when either (a) the call to 27 thread in an "alertable" state, so it wakes up when either (a) the
26 ReadDirectoryChangesW completes, or (b) the main thread instructs 28 call to ReadDirectoryChangesW completes, or (b) the main thread
27 the worker thread to terminate by sending it an APC, see below. 29 instructs the worker thread to terminate by sending it an APC, see
30 below.
28 31
29 When the ReadDirectoryChangesW call completes, its completion 32 When the ReadDirectoryChangesW call completes, its completion
30 routine watch_completion is automatically called. watch_completion 33 routine watch_completion is automatically called. watch_completion
@@ -59,9 +62,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
59 bound to a command. The default binding is w32notify-handle-event, 62 bound to a command. The default binding is w32notify-handle-event,
60 defined on subr.el. 63 defined on subr.el.
61 64
62 After w32_read_socket or w32_console_read_socket is done processing 65 After w32_read_socket or w32_console_read_socket are done
63 the notifications, it resets a flag signaling to all watch worker 66 processing the notifications, they reset a flag signaling to all
64 threads that the notifications buffer is available for more input. 67 watch worker threads that the notifications buffer is available for
68 more input.
65 69
66 When the watch is removed by a call to w32notify-rm-watch, the main 70 When the watch is removed by a call to w32notify-rm-watch, the main
67 thread requests that the worker thread terminates by queuing an APC 71 thread requests that the worker thread terminates by queuing an APC
@@ -72,9 +76,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
72 watch_completion function is called one last time with the 76 watch_completion function is called one last time with the
73 ERROR_OPERATION_ABORTED status, which causes it to clean up and set 77 ERROR_OPERATION_ABORTED status, which causes it to clean up and set
74 a flag telling watch_worker to exit without issuing another 78 a flag telling watch_worker to exit without issuing another
75 ReadDirectoryChangesW call. The main thread waits for some time 79 ReadDirectoryChangesW call. Since watch_worker is the thread
76 for the worker thread to exit, and if it doesn't, terminates it 80 procedure of the worker thread, exiting it causes the thread to
77 forcibly. */ 81 exit. The main thread waits for some time for the worker thread to
82 exit, and if it doesn't, terminates it forcibly. */
78 83
79#include <stddef.h> 84#include <stddef.h>
80#include <errno.h> 85#include <errno.h>
@@ -185,9 +190,9 @@ watch_end (ULONG_PTR arg)
185 } 190 }
186} 191}
187 192
188/* A completion routine (a.k.a. APC function) for handling events read 193/* A completion routine (a.k.a. "APC function") for handling events
189 by ReadDirectoryChangesW. Called by the OS when the thread which 194 read by ReadDirectoryChangesW. Called by the OS when the thread
190 issued the asynchronous ReadDirectoryChangesW call is in the 195 which issued the asynchronous ReadDirectoryChangesW call is in the
191 "alertable state", i.e. waiting inside SleepEx call. */ 196 "alertable state", i.e. waiting inside SleepEx call. */
192VOID CALLBACK 197VOID CALLBACK
193watch_completion (DWORD status, DWORD bytes_ret, OVERLAPPED *io_info) 198watch_completion (DWORD status, DWORD bytes_ret, OVERLAPPED *io_info)