A workaround for 100% CPU consumption issue in NIO selectors, suggested by David M. Lloyd
This commit is contained in:
parent
d0890c1af0
commit
72a35e3e24
@ -216,7 +216,7 @@ class NioDatagramWorker implements Runnable {
|
||||
}
|
||||
|
||||
try {
|
||||
int selectedKeyCount = selector.select(500);
|
||||
selector.select(500);
|
||||
|
||||
// 'wakenUp.compareAndSet(false, true)' is always evaluated
|
||||
// before calling 'selector.wakeup()' to reduce the wake-up
|
||||
@ -252,10 +252,7 @@ class NioDatagramWorker implements Runnable {
|
||||
|
||||
processRegisterTaskQueue();
|
||||
processWriteTaskQueue();
|
||||
|
||||
if (selectedKeyCount > 0) {
|
||||
processSelectedKeys(selector.selectedKeys());
|
||||
}
|
||||
processSelectedKeys(selector.selectedKeys());
|
||||
|
||||
// Exit the loop when there's nothing to handle (the registered
|
||||
// key set is empty.
|
||||
|
@ -155,7 +155,7 @@ class NioWorker implements Runnable {
|
||||
}
|
||||
|
||||
try {
|
||||
int selectedKeyCount = selector.select(500);
|
||||
selector.select(500);
|
||||
|
||||
// 'wakenUp.compareAndSet(false, true)' is always evaluated
|
||||
// before calling 'selector.wakeup()' to reduce the wake-up
|
||||
@ -191,10 +191,7 @@ class NioWorker implements Runnable {
|
||||
|
||||
processRegisterTaskQueue();
|
||||
processWriteTaskQueue();
|
||||
|
||||
if (selectedKeyCount > 0) {
|
||||
processSelectedKeys(selector.selectedKeys());
|
||||
}
|
||||
processSelectedKeys(selector.selectedKeys());
|
||||
|
||||
// Exit the loop when there's nothing to handle.
|
||||
// The shutdown flag is used to delay the shutdown of this
|
||||
|
Loading…
Reference in New Issue
Block a user