Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the ClusterListener, ServerListener, ServerMonitorListener API docs relevant to thread-safety #1208

Merged
merged 5 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions driver-core/src/main/com/mongodb/event/ClusterListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
/**
* A listener for cluster-related events.
* <p>
* It does not have to be thread-safe. All events received by {@link ClusterListener}, {@link ServerListener},
* All events received by {@link ClusterListener}, {@link ServerListener},
* {@link ServerMonitorListener} are totally ordered (and the event order implies the happens-before order), provided that the listeners
* are not shared by different {@code MongoClient}s. This means that even if you have a single class implementing all of
* {@link ClusterListener}, {@link ServerListener}, {@link ServerMonitorListener}, it does not have to be thread-safe.
* are not shared by different {@code MongoClient}s. This guarantee holds even if you have a single class implementing
* all of {@link ClusterListener}, {@link ServerListener}, {@link ServerMonitorListener}. However, this guarantee does not mean that
* implementations automatically do not need to synchronize memory accesses to prevent data races.
* For example, if data that the listener collects in memory is accessed outside of the normal execution of the listener
* by the {@code MongoClient}, then reading and writing actions must be synchronized.
* </p>
* @see ServerListener
* @see ServerMonitorListener
Expand Down
2 changes: 1 addition & 1 deletion driver-core/src/main/com/mongodb/event/ServerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* A listener for server-related events
* <p>
* It does not have to be thread-safe, see {@link ClusterListener} for the details regarding the order of events.
* See {@link ClusterListener} for the details regarding the order of events and memory synchronization.
* </p>
* @see ClusterListener
* @see ServerMonitorListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* A listener for server monitor-related events
* <p>
* It does not have to be thread-safe, see {@link ClusterListener} for the details regarding the order of events.
* See {@link ClusterListener} for the details regarding the order of events and memory synchronization.
* </p>
* @see ClusterListener
* @see ServerListener
Expand Down