Skip to content

Commit 25d5eb7

Browse files
committed
Add comment to explain why events is thread-safe
1 parent 94c3aee commit 25d5eb7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/java/engineering/swat/watch/impl/overflows/MemorylessRescanner.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ protected Generator newGenerator(Path path, WatchScope scope) {
6565
}
6666

6767
protected class Generator extends BaseFileVisitor {
68+
// When this class is used as intended, `events` is accessed only by one
69+
// thread (the one that executes `Files.walkFileTree` via
70+
// `BaseFileVisitor.walkFileTree`), so no additional thread-safety
71+
// measures are needed to protect it from concurrent accesses.
6872
protected final List<WatchEvent> events = new ArrayList<>();
6973

7074
public Generator(Path path, WatchScope scope) {

0 commit comments

Comments
 (0)