Commit 5ac454b
gopls/internal/filewatcher: read and process event in separate goroutine
To work around the potential deadlock in fsnotify, the file watcher had
to run dir watching in a separate go routine which make the file watcher
complicated and harder to reason about.
This CL change the solution by having two methods with clear
responsibility but still work around the issue:
The run() method is designed to be highly responsive, ensures the
fsnotify's events and errors are consumed as soon as possible.
A process() method is created to actually handles the time-consuming
event processing. Including event conversion, dir watching... As a
result, the processor is now processing events in sequence and there
is no need for cancelling the ongoing watch attempt.
To keep things simple, the input handler function is now separate as
event handler and error handler. The event handler is promised to be
called sequentially but the error handler maybe called concurrently.
For golang/go#74292
Change-Id: I58b06be2022e9a94b4770eb88abff82e94d65ed9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/715882
Auto-Submit: Hongxiang Jiang <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>1 parent 9d65a90 commit 5ac454b
File tree
3 files changed
+197
-209
lines changed- gopls/internal
- cmd
- filewatcher
3 files changed
+197
-209
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
115 | 113 | | |
116 | 114 | | |
117 | 115 | | |
| |||
127 | 125 | | |
128 | 126 | | |
129 | 127 | | |
130 | | - | |
| 128 | + | |
131 | 129 | | |
132 | 130 | | |
133 | 131 | | |
| |||
0 commit comments