Skip to content

Commit

Permalink
Make some member variables of Dispatcher volatile (apache#5193)
Browse files Browse the repository at this point in the history
(cherry picked from commit b9e7bf3)
  • Loading branch information
Masahiro Sakamoto authored and wolfstudy committed Nov 19, 2019
1 parent 850b123 commit 90ec8e1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public abstract class AbstractDispatcherMultipleConsumers extends AbstractBaseDi

protected final CopyOnWriteArrayList<Consumer> consumerList = new CopyOnWriteArrayList<>();
protected final ObjectSet<Consumer> consumerSet = new ObjectHashSet<>();
protected int currentConsumerRoundRobinIndex = 0;
protected volatile int currentConsumerRoundRobinIndex = 0;

protected static final int FALSE = 0;
protected static final int TRUE = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ public class PersistentDispatcherMultipleConsumers extends AbstractDispatcherMul
private Optional<DelayedDeliveryTracker> delayedDeliveryTracker = Optional.empty();
private final boolean isDelayedDeliveryEnabled;

private boolean havePendingRead = false;
private boolean havePendingReplayRead = false;
private volatile boolean havePendingRead = false;
private volatile boolean havePendingReplayRead = false;
private boolean shouldRewindBeforeReadingOrReplaying = false;
protected final String name;

protected int totalAvailablePermits = 0;
private int readBatchSize;
protected volatile int totalAvailablePermits = 0;
private volatile int readBatchSize;
private final Backoff readFailureBackoff = new Backoff(15, TimeUnit.SECONDS, 1, TimeUnit.MINUTES, 0, TimeUnit.MILLISECONDS);
private static final AtomicIntegerFieldUpdater<PersistentDispatcherMultipleConsumers> TOTAL_UNACKED_MESSAGES_UPDATER =
AtomicIntegerFieldUpdater.newUpdater(PersistentDispatcherMultipleConsumers.class, "totalUnackedMessages");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ public final class PersistentDispatcherSingleActiveConsumer extends AbstractDisp
private final PersistentTopic topic;
private final ManagedCursor cursor;
private final String name;
private Optional<DispatchRateLimiter> dispatchRateLimiter = Optional.empty();;
private Optional<DispatchRateLimiter> dispatchRateLimiter = Optional.empty();

private volatile boolean havePendingRead = false;

private int readBatchSize;
private volatile int readBatchSize;
private final Backoff readFailureBackoff = new Backoff(15, TimeUnit.SECONDS, 1, TimeUnit.MINUTES, 0, TimeUnit.MILLISECONDS);
private final ServiceConfiguration serviceConfig;
private volatile ScheduledFuture<?> readOnActiveConsumerTask = null;
Expand Down

0 comments on commit 90ec8e1

Please sign in to comment.