From 1bef7b31f37c8f11cf4c20e139f6582f27924dbc Mon Sep 17 00:00:00 2001 From: "xiaofan.chen" Date: Sat, 31 Aug 2024 20:45:36 +0800 Subject: [PATCH] chore: better code style --- .../core/protocol/DefaultAutoBatchFlushEndpoint.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/lettuce/core/protocol/DefaultAutoBatchFlushEndpoint.java b/src/main/java/io/lettuce/core/protocol/DefaultAutoBatchFlushEndpoint.java index b1aad017b9..b2865f04f1 100644 --- a/src/main/java/io/lettuce/core/protocol/DefaultAutoBatchFlushEndpoint.java +++ b/src/main/java/io/lettuce/core/protocol/DefaultAutoBatchFlushEndpoint.java @@ -1266,25 +1266,23 @@ public void execute(Runnable task) { cur = this.owner; if (isOwnerCurrentThreadAndPreemptPrevented(cur)) { // already prevented preemption, safe to skip expensive add/done calls - executeInOwnerWithPreemptPrevention(task, false); + task.run(); return; } } while (!OWNER.compareAndSet(this, cur, cur.toAdd(1))); if (cur.isCurrentThread()) { - executeInOwnerWithPreemptPrevention(task, true); + executeInOwnerWithPreemptPrevention(task); } else { - cur.thread.execute(() -> executeInOwnerWithPreemptPrevention(task, true)); + cur.thread.execute(() -> executeInOwnerWithPreemptPrevention(task)); } } - private void executeInOwnerWithPreemptPrevention(Runnable task, boolean added) { + private void executeInOwnerWithPreemptPrevention(Runnable task) { try { task.run(); } finally { - if (added) { - done(1); - } + done(1); } }