Skip to content

Commit d33858f

Browse files
committed
Improve comments
1 parent 7490e1b commit d33858f

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

src/main/java/engineering/swat/watch/impl/mac/NativeEventHandler.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,20 @@
3333

3434
/**
3535
* <p>
36-
* Handler for native events, intended to be used for the construction of
37-
* JDK's {@link WatchEvent}s (and continue downstream consumption).
36+
* Handler for native events, intended to be used in a {@link NativeEventStream}
37+
* callback to construct {@link WatchEvent}s (and propagate them for downstream
38+
* consumption).
3839
* </p>
3940
*
4041
* <p>
41-
* In each call, the types of {@code kind} and {@code context} depend
42+
* In each invocation, the types of {@code kind} and {@code context} depend
4243
* specifically on the given native event: they're {@code Kind<Path>} and
4344
* {@code Path} for non-overflows, but they're {@code Kind<Object>} and
4445
* {@code Object} for overflows. This precision is needed to construct
45-
* {@link WatchEvent}s, where the types of {@code kind} and {@code context}
46-
* are correlated. Note: {@link java.util.function.BiConsumer} doesn't give
47-
* the required precision (i.e., its type parameters are initialized only
48-
* once for all calls).
46+
* {@link WatchEvent}s, where the types of {@code kind} and {@code context} need
47+
* to be correlated. Note: {@link java.util.function.BiConsumer} doesn't give
48+
* the required precision (i.e., its type parameters are initialized only once
49+
* for all invocations).
4950
* </p>
5051
*/
5152
@FunctionalInterface

src/main/java/engineering/swat/watch/impl/mac/NativeEventStream.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,20 @@
5959
import engineering.swat.watch.impl.mac.apis.FileSystemEvents.FSEventStreamCallback;
6060

6161
// Note: This file is designed to be the only place in this package where JNA is
62-
// used and/or the native APIs are called. If the need to do so arises outside
62+
// used and/or the native APIs are invoked. If the need to do so arises outside
6363
// this file, consider extending this file to offer the required services
6464
// without exposing JNA and/or the native APIs.
6565

6666
/**
6767
* <p>
68-
* Stream of native events for a path, issued by macOS.
68+
* Stream of native events for a path, issued by macOS. It's a facade-like
69+
* object that hides the low-level native APIs behind a higher-level interface.
6970
* </p>
7071
*
7172
* <p>
7273
* Note: Methods {@link #open()} and {@link #close()} synchronize on this object
7374
* to avoid races. The synchronization overhead is expected to be negligible, as
74-
* these methods are expected to be rarely called.
75+
* these methods are expected to be rarely invoked.
7576
* </p>
7677
*/
7778
public class NativeEventStream implements Closeable {

src/test/java/engineering/swat/watch/impl/mac/APIs.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void smokeTest() throws IOException {
107107
}
108108

109109
public static void main(String[] args) throws IOException {
110-
var s = "/Users/sungshik/Desktop/tmp";
110+
var s = args[0];
111111
var handler = (MinimalWorkingExample.EventHandler) (path, flags, id) -> {
112112
LOGGER.info(prettyPrint(path, flags, id));
113113
};
@@ -130,9 +130,9 @@ private static String prettyPrint(String path, int flags, long id) {
130130
}
131131

132132
private static class MinimalWorkingExample implements Closeable {
133-
FileSystemEvents.FSEventStreamCallback callback;
134-
Pointer stream;
135-
Pointer queue;
133+
private FileSystemEvents.FSEventStreamCallback callback;
134+
private Pointer stream;
135+
private Pointer queue;
136136

137137
public MinimalWorkingExample(String s, EventHandler handler) {
138138

0 commit comments

Comments
 (0)