Created
July 5, 2016 14:13
-
-
Save TanyaGaleyev/7eb3d8093344ca404dc31859402deb5c to your computer and use it in GitHub Desktop.
Simple application utilizing reactor to demonstrate 100% CPU load on 32 bit Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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