Commit 939a8f8b authored by Florian Fittkau's avatar Florian Fittkau

reduced waiting CPU impact

parent 6e800e6c
......@@ -6,7 +6,6 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.concurrent.locks.LockSupport;
import explorviz.live_trace_processing.Constants;
import explorviz.live_trace_processing.StringRegistry;
......@@ -66,7 +65,10 @@ IRecordSender {
@Override
public void connect() throws IOException {
while (shouldDisconnect) {
LockSupport.parkNanos(1);
try {
Thread.sleep(1);
} catch (final InterruptedException e) {
}
}
socketChannel = SocketChannel.open(new InetSocketAddress(getProviderURL().getHost(),
......@@ -101,7 +103,10 @@ IRecordSender {
@Override
public void send(final ByteBuffer buffer) {
while ((socketChannel == null) || (!socketChannel.isConnected())) {
LockSupport.parkNanos(1);
try {
Thread.sleep(1);
} catch (final InterruptedException e) {
}
}
try {
......
......@@ -9,7 +9,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -69,7 +68,10 @@ public final class TCPReader implements IPeriodicTimeSignalReceiver {
recordArrayEvent.getValues()[0] = new TimedPeriodRecord();
recordArrayEvent.setValueSize(1);
while (!queue.offer(recordArrayEvent)) {
LockSupport.parkNanos(1);
try {
Thread.sleep(1);
} catch (final InterruptedException e) {
}
}
merger.deregisterProducer(queue);
}
......
......@@ -7,7 +7,6 @@ import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.locks.LockSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -725,7 +724,10 @@ class TCPReaderOneClient extends Thread {
arrayEvent.setValueSize(outputBufferIndex);
while (!queue.offer(arrayEvent)) {
LockSupport.parkNanos(1);
try {
Thread.sleep(1);
} catch (final InterruptedException e) {
}
}
outputBuffer = savedBuffer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment