com.lmax.disruptor.BusySpinWaitStrategy Java Examples
The following examples show how to use
com.lmax.disruptor.BusySpinWaitStrategy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FastEventServiceImpl.java From redtorch with MIT License | 6 votes |
@Override public void afterPropertiesSet() throws Exception { if ("BusySpinWaitStrategy".equals(waitStrategy)) { disruptor = new Disruptor<FastEvent>(new FastEventFactory(), 65536, DaemonThreadFactory.INSTANCE, ProducerType.MULTI, new BusySpinWaitStrategy()); } else if ("SleepingWaitStrategy".equals(waitStrategy)) { disruptor = new Disruptor<FastEvent>(new FastEventFactory(), 65536, DaemonThreadFactory.INSTANCE, ProducerType.MULTI, new SleepingWaitStrategy()); } else if ("BlockingWaitStrategy".equals(waitStrategy)) { disruptor = new Disruptor<FastEvent>(new FastEventFactory(), 65536, DaemonThreadFactory.INSTANCE, ProducerType.MULTI, new BlockingWaitStrategy()); } else { disruptor = new Disruptor<FastEvent>(new FastEventFactory(), 65536, DaemonThreadFactory.INSTANCE, ProducerType.MULTI, new YieldingWaitStrategy()); } ringBuffer = disruptor.start(); }
Example #2
Source File: DisruptorUtil.java From logging-log4j2 with Apache License 2.0 | 6 votes |
static WaitStrategy createWaitStrategy(final String propertyName, final long timeoutMillis) { final String strategy = PropertiesUtil.getProperties().getStringProperty(propertyName, "TIMEOUT"); LOGGER.trace("property {}={}", propertyName, strategy); final String strategyUp = strategy.toUpperCase(Locale.ROOT); // TODO Refactor into Strings.toRootUpperCase(String) switch (strategyUp) { // TODO Define a DisruptorWaitStrategy enum? case "SLEEP": return new SleepingWaitStrategy(); case "YIELD": return new YieldingWaitStrategy(); case "BLOCK": return new BlockingWaitStrategy(); case "BUSYSPIN": return new BusySpinWaitStrategy(); case "TIMEOUT": return new TimeoutBlockingWaitStrategy(timeoutMillis, TimeUnit.MILLISECONDS); default: return new TimeoutBlockingWaitStrategy(timeoutMillis, TimeUnit.MILLISECONDS); } }
Example #3
Source File: RingBufferSupplier.java From conga with Apache License 2.0 | 5 votes |
/** * Starts a background thread to process events */ public void start() { if (disruptor == null) { disruptor = new Disruptor<BufferEvent>(BufferEvent::new, queueDepth, threadFactory, ProducerType.SINGLE, new BusySpinWaitStrategy()); // Connect the handler disruptor.handleEventsWith(eventHandler); // Start the Disruptor, starts all threads running disruptor.start(); ringBuffer = disruptor.getRingBuffer(); } }
Example #4
Source File: DisruptorModule.java From phoenix-omid with Apache License 2.0 | 5 votes |
@Override protected void configure() { switch (config.getWaitStrategyEnum()) { // A low-cpu usage Disruptor configuration for using in local/test environments case LOW_CPU: bind(WaitStrategy.class).annotatedWith(Names.named("PersistenceStrategy")).to(BlockingWaitStrategy.class); bind(WaitStrategy.class).annotatedWith(Names.named("ReplyStrategy")).to(BlockingWaitStrategy.class); bind(WaitStrategy.class).annotatedWith(Names.named("RetryStrategy")).to(BlockingWaitStrategy.class); break; // The default high-cpu usage Disruptor configuration for getting high throughput on production environments case HIGH_THROUGHPUT: default: bind(WaitStrategy.class).annotatedWith(Names.named("PersistenceStrategy")).to(BusySpinWaitStrategy.class); bind(WaitStrategy.class).annotatedWith(Names.named("ReplyStrategy")).to(BusySpinWaitStrategy.class); bind(WaitStrategy.class).annotatedWith(Names.named("RetryStrategy")).to(YieldingWaitStrategy.class); break; } if (config.getLowLatency()) { bind(RequestProcessor.class).to(RequestProcessorSkipCT.class).in(Singleton.class); bind(PersistenceProcessor.class).to(PersitenceProcessorNullImpl.class).in(Singleton.class); } else { bind(PersistenceProcessor.class).to(PersistenceProcessorImpl.class).in(Singleton.class); bind(RequestProcessor.class).to(RequestProcessorPersistCT.class).in(Singleton.class); } bind(ReplyProcessor.class).to(ReplyProcessorImpl.class).in(Singleton.class); bind(RetryProcessor.class).to(RetryProcessorImpl.class).in(Singleton.class); }
Example #5
Source File: DisruptorBenchmark.java From benchmarks with Apache License 2.0 | 5 votes |
@Setup public synchronized void setup() throws InterruptedException { for (int i = 0; i < MAX_THREAD_COUNT; i++) { responseQueues[i] = new OneToOneConcurrentArrayQueue<>(RESPONSE_QUEUE_CAPACITY); } values = new int[burstLength]; for (int i = 0; i < burstLength; i++) { values[i] = -(burstLength - i); } handler = new Handler(responseQueues); disruptor = new Disruptor<>( Message::new, Configuration.SEND_QUEUE_CAPACITY, (ThreadFactory)Thread::new, ProducerType.MULTI, new BusySpinWaitStrategy()); disruptor.handleEventsWith(handler); disruptor.start(); handler.waitForStart(); }
Example #6
Source File: WaitStrategyTypeTest.java From disruptor-spring-manager with MIT License | 5 votes |
@Test public void test_All_WaitStrategies() { assertTrue(WaitStrategyType.BLOCKING.instance() instanceof BlockingWaitStrategy); assertTrue(WaitStrategyType.BUSY_SPIN.instance() instanceof BusySpinWaitStrategy); assertTrue(WaitStrategyType.LITE_BLOCKING.instance() instanceof LiteBlockingWaitStrategy); assertTrue(WaitStrategyType.SLEEPING_WAIT.instance() instanceof SleepingWaitStrategy); assertTrue(WaitStrategyType.YIELDING.instance() instanceof YieldingWaitStrategy); }
Example #7
Source File: DisruptorIntegrationTest.java From tutorials with MIT License | 4 votes |
@Before public void setUp() throws Exception { waitStrategy = new BusySpinWaitStrategy(); }