当前位置: 首页>>代码示例>>Java>>正文


Java Sequence.get方法代码示例

本文整理汇总了Java中com.lmax.disruptor.Sequence.get方法的典型用法代码示例。如果您正苦于以下问题:Java Sequence.get方法的具体用法?Java Sequence.get怎么用?Java Sequence.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.lmax.disruptor.Sequence的用法示例。


在下文中一共展示了Sequence.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: waitFor

import com.lmax.disruptor.Sequence; //导入方法依赖的package包/类
public long waitFor(long sequence, Sequence cursorSequence, Sequence dependentSequence, SequenceBarrier barrier) throws AlertException, InterruptedException {
    if(cursorSequence.get() < sequence) {
        this.lock.lock();

        try {
            while(cursorSequence.get() < sequence) {
                barrier.checkAlert();
                this.processorNotifyCondition.await();
            }
        } finally {
            this.lock.unlock();
        }
    }

    long availableSequence;
    while((availableSequence = dependentSequence.get()) < sequence) {
        barrier.checkAlert();
        LockSupport.parkNanos(1L);
    }

    return availableSequence;
}
 
开发者ID:wso2,项目名称:andes,代码行数:23,代码来源:SleepingBlockingWaitStrategy.java

示例2: hasBacklog

import com.lmax.disruptor.Sequence; //导入方法依赖的package包/类
/**
 * Confirms if all messages have been consumed by all event processors
 */
private boolean hasBacklog() {
    final long cursor = ringBuffer.getCursor();
    for (final Sequence consumer : consumerRepository.getLastSequenceInChain(false)) {
        if (cursor > consumer.get()) {
            return true;
        }
    }
    return false;
}
 
开发者ID:winwill2012,项目名称:disruptor-code-analysis,代码行数:13,代码来源:Disruptor.java

示例3: waitFor

import com.lmax.disruptor.Sequence; //导入方法依赖的package包/类
public long waitFor(
	long sequence,
	Sequence cursor,
	Sequence dependentSequence,
	SequenceBarrier barrier
) throws AlertException, InterruptedException, TimeoutException {
	long availableSequence;
	if ((availableSequence = cursor.get()) < sequence) {
		flush();
		synchronized (lock) {
			++numWaiters;
			while ((availableSequence = cursor.get()) < sequence) {
				if (state == State.STOPPED) {
					disruptor.halt();
					throw AlertException.INSTANCE;
				}
				barrier.checkAlert();
				//*/
				lock.wait();
				/*/
				Thread.sleep(1);
				//*/
			}
			--numWaiters;
		}
	}
	while ((availableSequence = dependentSequence.get()) < sequence) {
		barrier.checkAlert();
	}

	return availableSequence;
}
 
开发者ID:vladimirdolzhenko,项目名称:gflogger,代码行数:33,代码来源:LoggerServiceImpl.java

示例4: waitFor

import com.lmax.disruptor.Sequence; //导入方法依赖的package包/类
@Override
public long waitFor(long sequence,
                    Sequence cursor,
                    Sequence dependentSequence,
                    SequenceBarrier barrier) throws AlertException,
  InterruptedException,
  TimeoutException {
  long availableSequence;
  while ((availableSequence = dependentSequence.get()) < sequence) {
    barrier.checkAlert();
    LockSupport.parkNanos(parkFor);
  }
  return availableSequence;
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:15,代码来源:ParkWaitStrategy.java

示例5: waitFor

import com.lmax.disruptor.Sequence; //导入方法依赖的package包/类
@Override
public long waitFor(final long sequence, Sequence cursor, final Sequence dependentSequence, final SequenceBarrier barrier)
        throws AlertException, InterruptedException
{
    long availableSequence;

    while ((availableSequence = dependentSequence.get()) < sequence)
    {
        SpinHint.spinLoopHint();
        barrier.checkAlert();
    }

    return availableSequence;
}
 
开发者ID:epickrram,项目名称:perf-workshop,代码行数:15,代码来源:SpinLoopHintBusySpinWaitStrategy.java

示例6: waitFor

import com.lmax.disruptor.Sequence; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public long waitFor(final long sequence, final Sequence cursor,
		final Sequence dependentSequence, final SequenceBarrier barrier)
		throws AlertException, InterruptedException, TimeoutException {
	return cursor.get();
}
 
开发者ID:ricardopadilha,项目名称:dsys-snio,代码行数:10,代码来源:WakeupWaitStrategy.java

示例7: hasBacklog

import com.lmax.disruptor.Sequence; //导入方法依赖的package包/类
/**
 * Confirms if all messages have been consumed by all event processors
 */
private boolean hasBacklog() {
    final long cursor = ringBuffer.getCursor();
    for (Sequence consumer : consumerRepository.getLastSequenceInChain(false)) {
        if (cursor > consumer.get()) {
            return true;
        }
    }
    return false;
}
 
开发者ID:wen866595,项目名称:annotated-src,代码行数:13,代码来源:Disruptor.java

示例8: waitRequestOrTerminalEvent

import com.lmax.disruptor.Sequence; //导入方法依赖的package包/类
public static <T> boolean waitRequestOrTerminalEvent(
  Sequence pendingRequest,
  RingBuffer<MutableSignal<T>> ringBuffer,
  SequenceBarrier barrier,
  Subscriber<? super T> subscriber,
  AtomicBoolean isRunning
) {
  final long waitedSequence = ringBuffer.getCursor() + 1L;
  try {
    MutableSignal<T> event = null;
    while (pendingRequest.get() < 0l) {
      //pause until first request
      if (event == null) {
        barrier.waitFor(waitedSequence);
        event = ringBuffer.get(waitedSequence);

        if (event.type == MutableSignal.Type.COMPLETE) {
          try {
            subscriber.onComplete();
            return false;
          } catch (Throwable t) {
            Exceptions.throwIfFatal(t);
            subscriber.onError(t);
            return false;
          }
        } else if (event.type == MutableSignal.Type.ERROR) {
          subscriber.onError(event.error);
          return false;
        }
      } else {
        barrier.checkAlert();
      }
      LockSupport.parkNanos(1l);
    }
  } catch (TimeoutException te) {
    //ignore
  } catch (AlertException ae) {
    if (!isRunning.get()) {
      return false;
    }
  } catch (InterruptedException ie) {
    Thread.currentThread().interrupt();
  }

  return true;
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:47,代码来源:RingBufferSubscriberUtils.java


注:本文中的com.lmax.disruptor.Sequence.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。