/** * Construct {@link PhasedBackoffWaitStrategy} with fallback to {@link SleepingWaitStrategy} * * @param spinTimeout The maximum time in to busy spin for. * @param yieldTimeout The maximum time in to yield for. * @param units Time units used for the timeout values. * @return The constructed wait strategy. */ public static PhasedBackoffWaitStrategy withSleep( long spinTimeout, long yieldTimeout, TimeUnit units) { return new PhasedBackoffWaitStrategy( spinTimeout, yieldTimeout, units, new SleepingWaitStrategy(0)); }
protected WaitStrategy getWaitStrategy(String waitStrategyName, String configOptionName) { switch (waitStrategyName) { case "sleeping": return new SleepingWaitStrategy(); case "yielding": return new YieldingWaitStrategy(); case "blocking": return new BlockingWaitStrategy(); case "busy_spinning": return new BusySpinWaitStrategy(); default: log.warn("Invalid setting for [{}]:" + " Falling back to default: BlockingWaitStrategy.", configOptionName); return new BlockingWaitStrategy(); } }
private WaitStrategy getWaitStrategy(String waitStrategyName, String configOptionName) { switch (waitStrategyName) { case "sleeping": return new SleepingWaitStrategy(); case "yielding": return new YieldingWaitStrategy(); case "blocking": return new BlockingWaitStrategy(); case "busy_spinning": return new BusySpinWaitStrategy(); default: LOG.warn("Invalid setting for [{}]:" + " Falling back to default: BlockingWaitStrategy.", configOptionName); return new BlockingWaitStrategy(); } }
@Test public void shouldWaitForValue() throws Exception { assertWaitForWithDelayOf(50, new SleepingWaitStrategy()); } }
ProducerType.MULTI, new SleepingWaitStrategy()); RingBuffer<TestEvent> ringBuffer = disruptor.getRingBuffer(); disruptor.setDefaultExceptionHandler(new FatalExceptionHandler());
producerType, new SleepingWaitStrategy());
final RingBuffer<byte[]> ringBuffer = RingBuffer.createMultiProducer(factory, 4, new SleepingWaitStrategy());
break; case SLEEPING_WAIT: waitStrategy = new SleepingWaitStrategy(); break; case YIELDING_WAIT:
break; case SLEEPING_WAIT: waitStrategy = new SleepingWaitStrategy(); break; case YIELDING_WAIT:
/** * Construct {@link PhasedBackoffWaitStrategy} with fallback to {@link SleepingWaitStrategy} * * @param spinTimeout The maximum time in to busy spin for. * @param yieldTimeout The maximum time in to yield for. * @param units Time units used for the timeout values. * @return The constructed wait strategy. */ public static PhasedBackoffWaitStrategy withSleep( long spinTimeout, long yieldTimeout, TimeUnit units) { return new PhasedBackoffWaitStrategy( spinTimeout, yieldTimeout, units, new SleepingWaitStrategy(0)); }
/** * Set {@link com.lmax.disruptor.SleepingWaitStrategy} as wait strategy. * * @return {@literal this} */ public ProcessorSpec<T> sleepingWaitStrategy() { this.waitStrategy = new SleepingWaitStrategy(); return this; }
@Override public MessageQueue create(Option<ActorRef> owner, Option<ActorSystem> system) { return new DisruptorMessageQueue(bufferSize, new SleepingWaitStrategy()); } }
/** * Block by sleeping in a loop */ public static PhasedBackoffWaitStrategy withSleep( long spinTimeout, long yieldTimeout, TimeUnit units) { return new PhasedBackoffWaitStrategy( spinTimeout, yieldTimeout, units, new SleepingWaitStrategy(0)); }
/** * Block by sleeping in a loop */ public static PhasedBackoffWaitStrategy withSleep(long spinTimeout, long yieldTimeout, TimeUnit units) { return new PhasedBackoffWaitStrategy(spinTimeout, yieldTimeout, units, new SleepingWaitStrategy(0)); }
public WaitStrategy create() { switch (this) { case SLEEPING: return new SleepingWaitStrategy(); case BUSY_SPIN: return new BusySpinWaitStrategy(); case YIELDING: default: return new YieldingWaitStrategy(); } }
public MatchingEngine(final String instrument) { matchingUnit = new MatchingUnit(instrument); disruptor = new Disruptor<ValueEvent>(ValueEvent.EVENT_FACTORY, EXECUTOR, new SingleThreadedClaimStrategy(RING_SIZE), new SleepingWaitStrategy()); disruptor.handleEventsWith(journalHandler, replicatorHandler).then(matchingUnitHandler); ringBuffer = disruptor.start(); }
protected WaitStrategy createWaitStrategy() { switch (cpuConsumption()) { case LOW: return new BlockingWaitStrategy(); case NORMAL: return new SleepingWaitStrategy(); case HIGH: return new YieldingWaitStrategy(); case PHASED: return PhasedBackoffWaitStrategy.withLiteLock((int) 2.5e5, (int) 8.5e5, TimeUnit.NANOSECONDS); } return null; }
public LogEntryManager() { // init consumer this.logEntryStorage = new LogEntryMemoryStorage(); this.logEntryEventStat = new LogEntryEventStat(); this.consumer = new LogEntryEventHandler(this.logEntryStorage, this.logEntryEventStat); this.eventFactory = new LogEntryEventFactory(); this.ringBufferSize = LogConstants.DEFAULT_RINGBUFFER_SIZE; this.threadFactory = new CustomNameThreadFactory("devhelper", "RequestCaptureLog"); this.waitStrategy = new SleepingWaitStrategy(); }
public DisruptorQueueStorage() { this.logEntryRingBuffer = RingBuffer.createMultiProducer(LogEntryEvent.EVENT_FACTORY, LOGENTRY_BUFFER_SIZE, new SleepingWaitStrategy()); this.logEntrySequenceBarrier = logEntryRingBuffer.newBarrier(); this.logEntryEventProcessor = new BatchEventProcessor<LogEntryEvent>(logEntryRingBuffer, logEntrySequenceBarrier, new LogEntryEventHandler()); }
public HttpRequestRecordManager() { // init consumer this.recordStorage = new HttpRequestRecordMemoryStorage(); this.eventStat = new HttpRequestRecordEventStat(); this.consumer = new HttpRequestRecordEventHandler(this.recordStorage, this.eventStat); this.eventFactory = new HttpRequestRecordEventFactory(); this.ringBufferSize = RequestCaptureConstants.DEFAULT_RINGBUFFER_SIZE; this.threadFactory = new CustomNameThreadFactory("devhelper", "RequestCapture"); this.waitStrategy = new SleepingWaitStrategy(); // new TimeoutBlockingWaitStrategy(0, TimeUnit.MILLISECONDS); this.logEntryManager = new LogEntryManager(); }