use of org.agrona.concurrent.NoOpIdleStrategy in project Aeron by real-logic.
the class EmbeddedBufferClaimIpcThroughput method main.
public static void main(final String[] args) throws Exception {
MediaDriver.loadPropertiesFiles(args);
final AtomicBoolean running = new AtomicBoolean(true);
SigInt.register(() -> running.set(false));
final MediaDriver.Context ctx = new MediaDriver.Context().threadingMode(ThreadingMode.SHARED).sharedIdleStrategy(new NoOpIdleStrategy());
try (MediaDriver ignore = MediaDriver.launch(ctx);
Aeron aeron = Aeron.connect();
Publication publication = aeron.addPublication(CHANNEL, STREAM_ID);
Subscription subscription = aeron.addSubscription(CHANNEL, STREAM_ID)) {
final Subscriber subscriber = new Subscriber(running, subscription);
final Thread subscriberThread = new Thread(subscriber);
subscriberThread.setName("subscriber");
final Thread publisherThread = new Thread(new Publisher(running, publication));
publisherThread.setName("publisher");
final Thread rateReporterThread = new Thread(new RateReporter(running, subscriber));
rateReporterThread.setName("rate-reporter");
rateReporterThread.start();
subscriberThread.start();
publisherThread.start();
subscriberThread.join();
publisherThread.join();
rateReporterThread.join();
}
}
use of org.agrona.concurrent.NoOpIdleStrategy in project Aeron by real-logic.
the class EmbeddedExclusiveIpcThroughput method main.
public static void main(final String[] args) throws Exception {
MediaDriver.loadPropertiesFiles(args);
final AtomicBoolean running = new AtomicBoolean(true);
SigInt.register(() -> running.set(false));
final MediaDriver.Context ctx = new MediaDriver.Context().threadingMode(ThreadingMode.SHARED).sharedIdleStrategy(new NoOpIdleStrategy());
try (MediaDriver ignore = MediaDriver.launch(ctx);
Aeron aeron = Aeron.connect();
ExclusivePublication publication = aeron.addExclusivePublication(CHANNEL, STREAM_ID);
Subscription subscription = aeron.addSubscription(CHANNEL, STREAM_ID)) {
final Subscriber subscriber = new Subscriber(running, subscription);
final Thread subscriberThread = new Thread(subscriber);
subscriberThread.setName("subscriber");
final Thread publisherThread = new Thread(new Publisher(running, publication));
publisherThread.setName("publisher");
final Thread rateReporterThread = new Thread(new RateReporter(running, subscriber));
rateReporterThread.setName("rate-reporter");
rateReporterThread.start();
subscriberThread.start();
publisherThread.start();
subscriberThread.join();
publisherThread.join();
rateReporterThread.join();
}
}
use of org.agrona.concurrent.NoOpIdleStrategy in project Aeron by real-logic.
the class EmbeddedPingPong method main.
public static void main(final String[] args) throws Exception {
MediaDriver.loadPropertiesFiles(args);
final MediaDriver.Context ctx = new MediaDriver.Context().threadingMode(ThreadingMode.DEDICATED).conductorIdleStrategy(new BackoffIdleStrategy(1, 1, 1, 1)).receiverIdleStrategy(new NoOpIdleStrategy()).senderIdleStrategy(new NoOpIdleStrategy());
try (MediaDriver ignored = MediaDriver.launch(ctx)) {
final Thread pongThread = startPong(ignored.aeronDirectoryName());
pongThread.start();
runPing(ignored.aeronDirectoryName());
RUNNING.set(false);
pongThread.join();
System.out.println("Shutdown Driver...");
}
}
Aggregations