Search in sources :

Example 1 with NoOpIdleStrategy

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();
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) MediaDriver(io.aeron.driver.MediaDriver) NoOpIdleStrategy(org.agrona.concurrent.NoOpIdleStrategy)

Example 2 with NoOpIdleStrategy

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();
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) MediaDriver(io.aeron.driver.MediaDriver) NoOpIdleStrategy(org.agrona.concurrent.NoOpIdleStrategy)

Example 3 with NoOpIdleStrategy

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...");
    }
}
Also used : MediaDriver(io.aeron.driver.MediaDriver) NoOpIdleStrategy(org.agrona.concurrent.NoOpIdleStrategy) BackoffIdleStrategy(org.agrona.concurrent.BackoffIdleStrategy)

Aggregations

MediaDriver (io.aeron.driver.MediaDriver)3 NoOpIdleStrategy (org.agrona.concurrent.NoOpIdleStrategy)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 BackoffIdleStrategy (org.agrona.concurrent.BackoffIdleStrategy)1