• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java LiteBlockingWaitStrategy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.lmax.disruptor.LiteBlockingWaitStrategy的典型用法代码示例。如果您正苦于以下问题:Java LiteBlockingWaitStrategy类的具体用法?Java LiteBlockingWaitStrategy怎么用?Java LiteBlockingWaitStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LiteBlockingWaitStrategy类属于com.lmax.disruptor包,在下文中一共展示了LiteBlockingWaitStrategy类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: main

import com.lmax.disruptor.LiteBlockingWaitStrategy; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void main(String[] args) throws InterruptedException {
	//Executor that will be used to construct new threads for consumers
	Executor executor = Executors.newCachedThreadPool();
	//Specify the size of the ring buffer, must be power of 2.
	int bufferSize = 1024;
	//Disruptor<ObjectEvent> disruptor = new Disruptor<>(ObjectEvent::new, bufferSize, executor);
	Disruptor<ObjectEvent> disruptor = new Disruptor<>(ObjectEvent::new, bufferSize, executor, 
			ProducerType.SINGLE, new LiteBlockingWaitStrategy());

	disruptor.handleEventsWith(App::handleEvent1);
	disruptor.handleEventsWith(App::handleEvent2);
	
	//disruptor.handleEventsWith((event, sequence, endOfBatch) -> System.out.println("Event: " + event.getObject()));
	disruptor.start();

	produceEvents(disruptor);
}
 
开发者ID:smallnest,项目名称:DisruptorBootstrap,代码行数:19,代码来源:App.java


示例2: MetricsMetaAPIImpl

import com.lmax.disruptor.LiteBlockingWaitStrategy; //导入依赖的package包/类
/**
 * Creates a new MetricsMetaAPIImpl
 * @param properties The configuration properties
 */
public MetricsMetaAPIImpl(final Properties properties) {
	dataSource = SQLCompilerDataSource.getInstance(properties);
	sqlWorker = dataSource.getSQLWorker();
	tagPredicateCache = new TagPredicateCache(sqlWorker);
	fjPool = new ManagedForkJoinPool(getClass().getSimpleName(), Runtime.getRuntime().availableProcessors(), true, JMXHelper.objectName(getClass()));
	metaReader = new DefaultMetaReader(sqlWorker);
	dispatcher = new WorkQueueDispatcher("MetricsMetaDispatcher", Runtime.getRuntime().availableProcessors(), 1024, this, ProducerType.MULTI, new LiteBlockingWaitStrategy());
	log.info("Dispatcher Alive: {}", dispatcher.alive());
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:14,代码来源:MetricsMetaAPIImpl.java


示例3: initSpecDisruptor

import com.lmax.disruptor.LiteBlockingWaitStrategy; //导入依赖的package包/类
/**
 * 根据config初始化特殊通道
 *
 * @param symbol    事件
 * @param listeners 对应的监听器集合
 */
private void initSpecDisruptor(String symbol, List<ElectronsListener> listeners) {
    ExecutorService specPool = Executors.newFixedThreadPool(conf.getSpecCircuitNum(), new ThreadFactory() {

        final AtomicInteger cursor = new AtomicInteger(0);

        @Override
        public Thread newThread(Runnable r) {
            return new Thread(r, "Electrons Thread (from spec channel) : thread" + cursor.incrementAndGet());
        }
    });
    pools.add(specPool);

    Disruptor<ElectronsHolder> disruptor = new Disruptor<>(ElectronsHolder::new, conf.getSpecCircuitLen(), specPool, ProducerType.MULTI, new LiteBlockingWaitStrategy());
    disruptor.handleExceptionsWith(new ElecExceptionHandler("Spec Disruptor {" + symbol + "}"));

    //初始化管道并放入集合中
    SpecChannel specChannel = new SpecChannel(disruptor);
    if (conf.isBreaker()) {
        EventCountCircuitBreaker breaker = new EventCountCircuitBreaker(conf.getErrorNum(), conf.getPerUnit(), conf.getUnit(), conf.getCloseThreshold(), conf.getRest(), conf.getRestUnit());
        specChannel.setBreaker(breaker);
    }

    //构建listener顺序
    ListenerChainBuilderNew.buildChain(specChannel, listeners);

    channelMap.put(SPEC_CHANNEL_PREFIX + symbol, specChannel);
}
 
开发者ID:carryxyh,项目名称:Electrons,代码行数:34,代码来源:Dispatcher.java


示例4: initNormalChannel

import com.lmax.disruptor.LiteBlockingWaitStrategy; //导入依赖的package包/类
/**
 * 初始化正常管道,任何情况下都会有
 *
 * @param pool 线程池
 */
private void initNormalChannel(ExecutorService pool) {
    Disruptor<ElectronsHolder> normalDis = new Disruptor<>(ElectronsHolder::new, conf.getCircuitLen(), pool, ProducerType.MULTI, new LiteBlockingWaitStrategy());
    WorkHandler[] workHandlers = new WorkHandler[conf.getCircuitNum()];
    Arrays.fill(workHandlers, (WorkHandler<ElectronsHolder>) electronsHolder -> electronsHolder.handle());
    normalDis.handleEventsWithWorkerPool(workHandlers);
    normalDis.handleExceptionsWith(new ElecExceptionHandler("Normal Disruptor"));

    //初始化channel
    Channel normalChannel = new NormalChannel(normalDis);
    //配置限流相关
    normalChannel.confLimitRate(conf.isLimitRate(), conf.getPermitsPerSecond(), conf.isWarmup(), conf.getWarmupPeriod(), conf.getWarmPeriodUnit());
    channelMap.put(NORMAL_CHANNEL_KEY, normalChannel);
}
 
开发者ID:carryxyh,项目名称:Electrons,代码行数:19,代码来源:Dispatcher.java


示例5: test_All_WaitStrategies

import com.lmax.disruptor.LiteBlockingWaitStrategy; //导入依赖的package包/类
@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);
}
 
开发者ID:anair-it,项目名称:disruptor-spring-manager,代码行数:9,代码来源:WaitStrategyTypeTest.java


示例6: create

import com.lmax.disruptor.LiteBlockingWaitStrategy; //导入依赖的package包/类
/**
 * Create a new RingBufferProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy
 * and auto-cancel.
 * <p>
 * A new Cached ThreadExecutorPool will be implicitely created.
 *
 * @param <E> Type of processed signals
 * @return a fresh processor
 */
public static <E> RingBufferProcessor<E> create() {
  return create(RingBufferProcessor.class.getSimpleName(), SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), true);
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:13,代码来源:RingBufferProcessor.java


示例7: share

import com.lmax.disruptor.LiteBlockingWaitStrategy; //导入依赖的package包/类
/**
 * Create a new RingBufferProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy
 * and auto-cancel.
 * <p>
 * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that
 * will fan-in data.
 * <p>
 * A new Cached ThreadExecutorPool will be implicitely created.
 *
 * @param <E> Type of processed signals
 * @return a fresh processor
 */
public static <E> RingBufferProcessor<E> share() {
  return share(RingBufferProcessor.class.getSimpleName(), SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), true);
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:16,代码来源:RingBufferProcessor.java


示例8: create

import com.lmax.disruptor.LiteBlockingWaitStrategy; //导入依赖的package包/类
/**
 * Create a new RingBufferWorkProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy
 * and auto-cancel.
 * <p>
 * A new Cached ThreadExecutorPool will be implicitely created.
 *
 * @param <E> Type of processed signals
 * @return a fresh processor
 */
public static <E> RingBufferWorkProcessor<E> create() {
  return create(RingBufferWorkProcessor.class.getSimpleName(), SMALL_BUFFER_SIZE, new
    LiteBlockingWaitStrategy(), true);
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:14,代码来源:RingBufferWorkProcessor.java


示例9: share

import com.lmax.disruptor.LiteBlockingWaitStrategy; //导入依赖的package包/类
/**
 * Create a new RingBufferWorkProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy
 * and auto-cancel.
 * <p>
 * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that
 * will fan-in data.
 * <p>
 * A new Cached ThreadExecutorPool will be implicitely created.
 *
 * @param <E> Type of processed signals
 * @return a fresh processor
 */
public static <E> RingBufferWorkProcessor<E> share() {
  return share(RingBufferWorkProcessor.class.getSimpleName(), SMALL_BUFFER_SIZE, new
    LiteBlockingWaitStrategy(), true);
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:17,代码来源:RingBufferWorkProcessor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OpaquePartitionedTransactionalSpoutExecutor类代码示例发布时间:2022-05-23
下一篇:
Java TrustedCertificates类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap