* Removed 'volatile' from the member variables that are protected by synchronized (this) block
* Updated comments regarding thread safety
This commit is contained in:
parent
de8671df93
commit
e8c320c6c3
@ -71,8 +71,8 @@ public class DefaultChannelFuture implements ChannelFuture {
|
|||||||
private final Channel channel;
|
private final Channel channel;
|
||||||
private final boolean cancellable;
|
private final boolean cancellable;
|
||||||
|
|
||||||
private volatile ChannelFutureListener firstListener;
|
private ChannelFutureListener firstListener;
|
||||||
private volatile List<ChannelFutureListener> otherListeners;
|
private List<ChannelFutureListener> otherListeners;
|
||||||
private boolean done;
|
private boolean done;
|
||||||
private Throwable cause;
|
private Throwable cause;
|
||||||
private int waiters;
|
private int waiters;
|
||||||
@ -345,9 +345,11 @@ public class DefaultChannelFuture implements ChannelFuture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void notifyListeners() {
|
private void notifyListeners() {
|
||||||
// There won't be any visibility problem or concurrent modification
|
// This method doesn't need synchronization because:
|
||||||
// because 'ready' flag will be checked against both addListener and
|
// 1) This method is always called after synchronized (this) block.
|
||||||
// removeListener calls.
|
// Hence any listener list modification happens-before this method.
|
||||||
|
// 2) This method is only when 'done' is true. If 'done' is true,
|
||||||
|
// the listener list is never modified - see add/removeListener().
|
||||||
if (firstListener != null) {
|
if (firstListener != null) {
|
||||||
notifyListener(firstListener);
|
notifyListener(firstListener);
|
||||||
firstListener = null;
|
firstListener = null;
|
||||||
|
@ -48,8 +48,8 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
|||||||
|
|
||||||
private final ChannelGroup group;
|
private final ChannelGroup group;
|
||||||
final Map<Integer, ChannelFuture> futures;
|
final Map<Integer, ChannelFuture> futures;
|
||||||
private volatile ChannelGroupFutureListener firstListener;
|
private ChannelGroupFutureListener firstListener;
|
||||||
private volatile List<ChannelGroupFutureListener> otherListeners;
|
private List<ChannelGroupFutureListener> otherListeners;
|
||||||
private boolean done;
|
private boolean done;
|
||||||
int successCount;
|
int successCount;
|
||||||
int failureCount;
|
int failureCount;
|
||||||
@ -346,9 +346,11 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void notifyListeners() {
|
private void notifyListeners() {
|
||||||
// There won't be any visibility problem or concurrent modification
|
// This method doesn't need synchronization because:
|
||||||
// because 'ready' flag will be checked against both addListener and
|
// 1) This method is always called after synchronized (this) block.
|
||||||
// removeListener calls.
|
// Hence any listener list modification happens-before this method.
|
||||||
|
// 2) This method is only when 'done' is true. If 'done' is true,
|
||||||
|
// the listener list is never modified - see add/removeListener().
|
||||||
if (firstListener != null) {
|
if (firstListener != null) {
|
||||||
notifyListener(firstListener);
|
notifyListener(firstListener);
|
||||||
firstListener = null;
|
firstListener = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user