Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple application utilizing reactor to demonstrate 100% CPU load on 32 bit Linux
package org.ivan.experiments.reactor;
import reactor.core.publisher.WorkQueueProcessor;
import reactor.core.subscriber.SubmissionEmitter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.time.Duration;
public class FullCpu {
public static void main(String[] args) throws IOException {
WorkQueueProcessor<Object> processor = WorkQueueProcessor.share();
processor.buffer(Duration.ofMillis(1000L)).subscribe(o -> {
if (!o.isEmpty()) {
System.out.println("Consumed: " + o);
}
});
SubmissionEmitter<Object> emitter = processor.connectEmitter();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String l;
while (!(l = reader.readLine()).equals("q")) {
emitter.emit(l);
}
System.exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.