Abacn commented on code in PR #36750:
URL: https://github.com/apache/beam/pull/36750#discussion_r2500973825
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/fn/splittabledofn/RestrictionTrackers.java:
##########
@@ -55,35 +59,71 @@ protected RestrictionTrackerObserver(
}
@Override
- public synchronized boolean tryClaim(PositionT position) {
- if (delegate.tryClaim(position)) {
- claimObserver.onClaimed(position);
- return true;
- } else {
- claimObserver.onClaimFailed(position);
- return false;
+ public boolean tryClaim(PositionT position) {
+ lock.lock();
+ try {
+ if (delegate.tryClaim(position)) {
+ claimObserver.onClaimed(position);
+ evalueteProgress();
+ return true;
+ } else {
+ claimObserver.onClaimFailed(position);
+ return false;
+ }
+ } finally {
+ lock.unlock();
}
}
@Override
- public synchronized RestrictionT currentRestriction() {
- return delegate.currentRestriction();
+ public RestrictionT currentRestriction() {
+ lock.lock();
+ try {
+ return delegate.currentRestriction();
+ } finally {
+ lock.unlock();
+ }
}
@Override
- public synchronized SplitResult<RestrictionT> trySplit(double
fractionOfRemainder) {
- return delegate.trySplit(fractionOfRemainder);
+ public SplitResult<RestrictionT> trySplit(double fractionOfRemainder) {
+ lock.lock();
+ try {
+ SplitResult<RestrictionT> result =
delegate.trySplit(fractionOfRemainder);
+ evalueteProgress();
+ return result;
+ } finally {
+ lock.unlock();
+ }
}
@Override
- public synchronized void checkDone() throws IllegalStateException {
- delegate.checkDone();
+ public void checkDone() throws IllegalStateException {
+ lock.lock();
+ try {
+ delegate.checkDone();
+ } finally {
+ lock.unlock();
+ }
}
@Override
public IsBounded isBounded() {
return delegate.isBounded();
}
+
+ /** Evaluate progress if requested. */
+ protected void evalueteProgress() {
Review Comment:
also used in subclass, resovling
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]