com.lmax.disruptor.WaitStrategy类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(187)

本文整理了Java中com.lmax.disruptor.WaitStrategy类的一些代码示例,展示了WaitStrategy类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WaitStrategy类的具体详情如下:
包路径:com.lmax.disruptor.WaitStrategy
类名称:WaitStrategy

WaitStrategy介绍

[英]Strategy employed for making EventProcessors wait on a cursor Sequence.
[中]使事件处理器等待光标序列的策略。

代码示例

代码示例来源:origin: LMAX-Exchange/disruptor

@Override
  public void signalAllWhenBlocking()
  {
    fallbackStrategy.signalAllWhenBlocking();
  }
}

代码示例来源:origin: LMAX-Exchange/disruptor

@Override
public long waitFor(final long sequence)
  throws AlertException, InterruptedException, TimeoutException
{
  checkAlert();
  long availableSequence = waitStrategy.waitFor(sequence, cursorSequence, dependentSequence, this);
  if (availableSequence < sequence)
  {
    return availableSequence;
  }
  return sequencer.getHighestPublishedSequence(sequence, availableSequence);
}

代码示例来源:origin: mzheravin/exchange-core

@Override
public long tryWaitFor(long sequence, long spin) throws AlertException, InterruptedException, TimeoutException {
  checkAlert();
  long availableSequence = waitStrategy.tryWaitFor(sequence, cursorSequence, dependentSequence, this, spin);
  if (availableSequence < sequence) {
    return availableSequence;
  }
  return sequencer.getHighestPublishedSequence(sequence, availableSequence);
}

代码示例来源:origin: LMAX-Exchange/disruptor

@Override
public void alert()
{
  alerted = true;
  waitStrategy.signalAllWhenBlocking();
}

代码示例来源:origin: LMAX-Exchange/disruptor

if (timeDelta > yieldTimeoutNanos)
  return fallbackStrategy.waitFor(sequence, cursor, dependentSequence, barrier);

代码示例来源:origin: LMAX-Exchange/disruptor

/**
 * @see Sequencer#publish(long)
 */
@Override
public void publish(final long sequence)
{
  setAvailable(sequence);
  waitStrategy.signalAllWhenBlocking();
}

代码示例来源:origin: LMAX-Exchange/disruptor

public static void assertWaitForWithDelayOf(long sleepTimeMillis, WaitStrategy waitStrategy)
    throws InterruptedException, BrokenBarrierException, AlertException, TimeoutException
  {
    SequenceUpdater sequenceUpdater = new SequenceUpdater(sleepTimeMillis, waitStrategy);
    EXECUTOR.execute(sequenceUpdater);
    sequenceUpdater.waitForStartup();
    Sequence cursor = new Sequence(0);
    long sequence = waitStrategy.waitFor(0, cursor, sequenceUpdater.sequence, new DummySequenceBarrier());

    assertThat(sequence, is(0L));
  }
}

代码示例来源:origin: LMAX-Exchange/disruptor

/**
 * @see Sequencer#publish(long, long)
 */
@Override
public void publish(long lo, long hi)
{
  for (long l = lo; l <= hi; l++)
  {
    setAvailable(l);
  }
  waitStrategy.signalAllWhenBlocking();
}

代码示例来源:origin: com.lmax/disruptor

@Override
public long waitFor(final long sequence)
  throws AlertException, InterruptedException, TimeoutException
{
  checkAlert();
  long availableSequence = waitStrategy.waitFor(sequence, cursorSequence, dependentSequence, this);
  if (availableSequence < sequence)
  {
    return availableSequence;
  }
  return sequencer.getHighestPublishedSequence(sequence, availableSequence);
}

代码示例来源:origin: LMAX-Exchange/disruptor

/**
 * @see Sequencer#publish(long)
 */
@Override
public void publish(long sequence)
{
  cursor.set(sequence);
  waitStrategy.signalAllWhenBlocking();
}

代码示例来源:origin: com.lmax/disruptor

if (timeDelta > yieldTimeoutNanos)
  return fallbackStrategy.waitFor(sequence, cursor, dependentSequence, barrier);

代码示例来源:origin: alibaba/jstorm

/**
 * @see Sequencer#publish(long)
 */
@Override
public void publish(final long sequence) {
  setAvailable(sequence);
  waitStrategy.signalAllWhenBlocking();
}

代码示例来源:origin: camunda/camunda-bpm-reactor

@Override
public long waitFor(long sequence, Sequence cursor, Sequence dependentSequence, SequenceBarrier barrier)
 throws AlertException, InterruptedException, TimeoutException {
 return currentStrategy.waitFor(sequence, cursor, dependentSequence, barrier);
}

代码示例来源:origin: alibaba/jstorm

/**
 * @see Sequencer#publish(long)
 */
@Override
public void publish(long sequence) {
  cursor.set(sequence);
  waitStrategy.signalAllWhenBlocking();
}

代码示例来源:origin: harbby/presto-connectors

@Override
public long waitFor(final long sequence)
  throws AlertException, InterruptedException, TimeoutException
{
  checkAlert();
  long availableSequence = waitStrategy.waitFor(sequence, cursorSequence, dependentSequence, this);
  if (availableSequence < sequence)
  {
    return availableSequence;
  }
  return sequencer.getHighestPublishedSequence(sequence, availableSequence);
}

代码示例来源:origin: alibaba/jstorm

/**
 * @see Sequencer#publish(long, long)
 */
@Override
public void publish(long lo, long hi) {
  for (long l = lo; l <= hi; l++) {
    setAvailable(l);
  }
  waitStrategy.signalAllWhenBlocking();
}

代码示例来源:origin: mzheravin/exchange-core

@Override
public long waitFor(final long sequence)
    throws AlertException, InterruptedException, TimeoutException {
  checkAlert();
  long availableSequence = waitStrategy.waitFor(sequence, cursorSequence, dependentSequence, this);
  if (availableSequence < sequence) {
    return availableSequence;
  }
  return sequencer.getHighestPublishedSequence(sequence, availableSequence);
}

代码示例来源:origin: LMAX-Exchange/disruptor

@Override
public void run()
{
  try
  {
    barrier.await();
    if (0 != sleepTime)
    {
      Thread.sleep(sleepTime);
    }
    sequence.incrementAndGet();
    waitStrategy.signalAllWhenBlocking();
  }
  catch (Exception e)
  {
    e.printStackTrace();
  }
}

代码示例来源:origin: xiaoguichao/mr

@Override
public long waitFor(final long sequence)
  throws AlertException, InterruptedException, TimeoutException
{
  checkAlert();
  long availableSequence = waitStrategy.waitFor(sequence, cursorSequence, dependentSequence, this);
  if (availableSequence < sequence)
  {
    return availableSequence;
  }
  return sequencer.getHighestPublishedSequence(sequence, availableSequence);
}

代码示例来源:origin: com.lmax/disruptor

@Override
  public void signalAllWhenBlocking()
  {
    fallbackStrategy.signalAllWhenBlocking();
  }
}

相关文章