Use sleep on non-x86 architectures to avoid high cpu usage
This commit is contained in:
parent
d666363b41
commit
4611461b3e
@ -50,11 +50,17 @@ public class ResponseReceiver extends Thread implements AutoCloseable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
int[] sortIndex;
|
int[] sortIndex;
|
||||||
try {
|
try {
|
||||||
while(!closeRequested || !registeredClients.isEmpty()) {
|
boolean useSpinWait = "amd64".equalsIgnoreCase(System.getProperty("os.arch"));
|
||||||
|
while (!closeRequested || !registeredClients.isEmpty()) {
|
||||||
int resultsCount = NativeClientAccess.receive(clientIds, eventIds, events, 2.0 /*seconds*/);
|
int resultsCount = NativeClientAccess.receive(clientIds, eventIds, events, 2.0 /*seconds*/);
|
||||||
|
|
||||||
if (resultsCount <= 0) {
|
if (resultsCount <= 0) {
|
||||||
|
if (useSpinWait) {
|
||||||
Thread.onSpinWait();
|
Thread.onSpinWait();
|
||||||
|
} else {
|
||||||
|
//noinspection BusyWait
|
||||||
|
Thread.sleep(20);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,6 +156,8 @@ public class ResponseReceiver extends Thread implements AutoCloseable {
|
|||||||
this.registeredClients.addAll(closedClients);
|
this.registeredClients.addAll(closedClients);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
} finally {
|
} finally {
|
||||||
this.closeWait.countDown();
|
this.closeWait.countDown();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user