Skip to content

Commit fb39f51

Browse files
committed
change: disable spinwait
Cherry-picked from d32f47f, 41f4462
1 parent a9910a1 commit fb39f51

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

c2me-base/src/main/java/com/ishland/c2me/base/common/scheduler/SingleThreadExecutor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ public void run() {
2828
return;
2929
}
3030

31-
// attempt to spin-wait before sleeping
32-
if (!pollTasks()) {
33-
Thread.interrupted(); // clear interrupt flag
34-
for (int i = 0; i < 5000; i ++) {
35-
if (pollTasks()) continue main_loop;
36-
LockSupport.parkNanos("Spin-waiting for tasks", 10_000); // 100us
37-
}
38-
}
31+
// // attempt to spin-wait before sleeping
32+
// if (!pollTasks()) {
33+
// Thread.interrupted(); // clear interrupt flag
34+
// for (int i = 0; i < 5000; i ++) {
35+
// if (pollTasks()) continue main_loop;
36+
// LockSupport.parkNanos("Spin-waiting for tasks", 10_000); // 100us
37+
// }
38+
// }
3939

4040
synchronized (sync) {
4141
if (this.size.get() != 0 || this.shutdown.get()) continue main_loop;

c2me-rewrites-chunkio/src/main/java/com/ishland/c2me/rewrites/chunkio/common/C2MEStorageThread.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ public void run() {
9393
this.closeFuture.complete(null);
9494
break;
9595
} else {
96-
// attempt to spin-wait before sleeping
97-
if (!pollTasks()) {
98-
Thread.interrupted(); // clear interrupt flag
99-
for (int i = 0; i < 5000; i ++) {
100-
if (pollTasks() || this.closing.get()) continue main_loop;
101-
LockSupport.parkNanos("Spin-waiting for tasks", 10_000); // 100us
102-
}
103-
}
96+
// // attempt to spin-wait before sleeping
97+
// if (!pollTasks()) {
98+
// Thread.interrupted(); // clear interrupt flag
99+
// for (int i = 0; i < 5000; i ++) {
100+
// if (pollTasks() || this.closing.get()) continue main_loop;
101+
// LockSupport.parkNanos("Spin-waiting for tasks", 10_000); // 100us
102+
// }
103+
// }
104104
synchronized (sync) {
105105
if (this.taskSize.get() != 0 || this.closing.get()) continue main_loop;
106106
try {

0 commit comments

Comments
 (0)