You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/09/17 03:18:58 UTC
[GitHub] [rocketmq] RongtongJin commented on a diff in pull request #5101: [ISSUE #5100] Recover the optimization of pull request #2885
RongtongJin commented on code in PR #5101:
URL: https://github.com/apache/rocketmq/pull/5101#discussion_r973532588
##########
store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java:
##########
@@ -62,36 +66,37 @@ protected void onWaitEnd() {
}
public void wakeupAll() {
- synchronized (this) {
- boolean needNotify = false;
-
- for (Boolean value : this.waitingThreadTable.values()) {
- needNotify = needNotify || !value;
- value = true;
+ boolean needNotify = false;
+ for (Map.Entry<Long, AtomicBoolean> entry : this.waitingThreadTable.entrySet()) {
+ if (entry.getValue().compareAndSet(false, true)) {
+ needNotify = true;
}
-
- if (needNotify) {
+ }
+ if (needNotify) {
+ synchronized (this) {
this.notifyAll();
}
}
}
public void allWaitForRunning(long interval) {
long currentThreadId = Thread.currentThread().getId();
+ AtomicBoolean notified = this.waitingThreadTable.computeIfAbsent(currentThreadId, k -> new AtomicBoolean(false));
+ if (notified.compareAndSet(true, false)) {
+ this.onWaitEnd();
+ return;
+ }
Review Comment:
done
--
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: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org