Skip to content

Commit

Permalink
change: disable spinwait
Browse files Browse the repository at this point in the history
  • Loading branch information
ishland committed Nov 29, 2024
1 parent 77c965b commit 491bc6a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/main/java/com/ishland/flowsched/executor/WorkerThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public void run() {
continue;
}

// attempt to spin-wait before sleeping
if (!pollTasks()) {
Thread.interrupted(); // clear interrupt flag
for (int i = 0; i < 1000; i ++) {
if (pollTasks()) continue main_loop;
LockSupport.parkNanos("Spin-waiting for tasks", 10_000); // 10us
}
}
// // attempt to spin-wait before sleeping
// if (!pollTasks()) {
// Thread.interrupted(); // clear interrupt flag
// for (int i = 0; i < 1000; i ++) {
// if (pollTasks()) continue main_loop;
// LockSupport.parkNanos("Spin-waiting for tasks", 10_000); // 10us
// }
// }

// LockSupport.parkNanos("Waiting for tasks", 1_000_000); // 1ms
synchronized (this.executorManager.workerMonitor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ private void mainLoop() {
return;
}

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

// LockSupport.parkNanos("Waiting for tasks", 1_000_000); // 1ms
synchronized (this.notifyMonitor) {
Expand Down

0 comments on commit 491bc6a

Please sign in to comment.