Search in sources :

Example 1 with ControllableIdleStrategy

use of org.agrona.concurrent.ControllableIdleStrategy in project Aeron by real-logic.

the class Configuration method agentIdleStrategy.

/**
     * Get the {@link IdleStrategy} that should be applied to {@link org.agrona.concurrent.Agent}s.
     *
     * @param strategyName       to be created.
     * @param controllableStatus status indicator for what the strategy should do.
     * @return the newly created IdleStrategy.
     */
public static IdleStrategy agentIdleStrategy(final String strategyName, final StatusIndicator controllableStatus) {
    IdleStrategy idleStrategy = null;
    switch(strategyName) {
        case DEFAULT_IDLE_STRATEGY:
            idleStrategy = new BackoffIdleStrategy(AGENT_IDLE_MAX_SPINS, AGENT_IDLE_MAX_YIELDS, AGENT_IDLE_MIN_PARK_NS, AGENT_IDLE_MAX_PARK_NS);
            break;
        case CONTROLLABLE_IDLE_STRATEGY:
            idleStrategy = new ControllableIdleStrategy(controllableStatus);
            controllableStatus.setOrdered(ControllableIdleStrategy.PARK);
            break;
        default:
            try {
                idleStrategy = (IdleStrategy) Class.forName(strategyName).newInstance();
            } catch (final Exception ex) {
                LangUtil.rethrowUnchecked(ex);
            }
            break;
    }
    return idleStrategy;
}
Also used : ControllableIdleStrategy(org.agrona.concurrent.ControllableIdleStrategy) BackoffIdleStrategy(org.agrona.concurrent.BackoffIdleStrategy) ControllableIdleStrategy(org.agrona.concurrent.ControllableIdleStrategy) IdleStrategy(org.agrona.concurrent.IdleStrategy) BackoffIdleStrategy(org.agrona.concurrent.BackoffIdleStrategy) ConfigurationException(io.aeron.driver.exceptions.ConfigurationException)

Aggregations

ConfigurationException (io.aeron.driver.exceptions.ConfigurationException)1 BackoffIdleStrategy (org.agrona.concurrent.BackoffIdleStrategy)1 ControllableIdleStrategy (org.agrona.concurrent.ControllableIdleStrategy)1 IdleStrategy (org.agrona.concurrent.IdleStrategy)1