merlimat commented on a change in pull request #4111: [pulsar-broker] schedule 
one add/read timeout task per ml/topic
URL: https://github.com/apache/pulsar/pull/4111#discussion_r278278038
 
 

 ##########
 File path: 
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
 ##########
 @@ -230,10 +229,15 @@
     final ManagedLedgerFactoryImpl factory;
     protected final ManagedLedgerMBeanImpl mbean;
     protected final Clock clock;
+    
     private static final AtomicLongFieldUpdater<ManagedLedgerImpl> 
READ_OP_COUNT_UPDATER = AtomicLongFieldUpdater
             .newUpdater(ManagedLedgerImpl.class, "readOpCount");
     private volatile long readOpCount = 0;
-
+    // last read-operation's callback to check read-timeout on it. 
+    private static final AtomicReferenceFieldUpdater<ManagedLedgerImpl, 
ReadEntryCallbackWrapper> LAST_READ_CALLBACK = AtomicReferenceFieldUpdater
+            .newUpdater(ManagedLedgerImpl.class, 
ReadEntryCallbackWrapper.class, "lastReadCallback");
+    private volatile ReadEntryCallbackWrapper lastReadCallback = null;
 
 Review comment:
   @rdhabalia Just one comment here. If we're just doing get/set operations on 
the variable, then we don't need the updater object since 
`LAST_READ_CALLBACK.set(this, someOtherVar)` would be equivalent to doing 
`lastReadCallback = someOtherVar` (provided that `lastReadCallback` is already 
`volatile`).
   
   We really need the updater if using `compareAndSet()` and similar ops.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to