91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 581KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-14
  • 語言: Java
  • 標簽: disruptor??

資源簡介

disruptor 的jar包和api 自帶了一個簡單的例子。帶注釋 不是官方的例子。 不過是轉別人的。 看了之后很容易明白。

資源截圖

代碼片段和文件信息

package?demo.test;


import?java.util.concurrent.ExecutorService;
import?java.util.concurrent.Executors;

import?org.junit.Before;
import?org.junit.Test;

import?com.lmax.disruptor.BatchEventProcessor;
import?com.lmax.disruptor.BlockingWaitStrategy;
import?com.lmax.disruptor.EventHandler;
import?com.lmax.disruptor.MultiThreadedClaimStrategy;
import?com.lmax.disruptor.RingBuffer;
import?com.lmax.disruptor.SequenceBarrier;
import?com.lmax.disruptor.SingleThreadedClaimStrategy;
import?com.lmax.disruptor.YieldingWaitStrategy;
import?com.lmax.disruptor.dsl.Disruptor;

public?class?DisruptorConceptProofTest?{

private?long?_journalistCount?=?0L;
//?用來驗證日志線程看到的最后一個事件值
private?int?_lastEventValue?=?0;
//?用來驗證日志線程看到了所有生產線程產生的事件
private?int?_journalistValueSum?=?0;
//?將事件保存在硬盤里的書記員線程
final?EventHandler?_journalist?=?new?EventHandler()?{
public?void?onEvent(final?TicketEvent?event?final?long?sequence
final?boolean?endOfBatch)?throws?Exception?{
_journalistCount++;
_lastEventValue?=?event.getValue();
_journalistValueSum?+=?_lastEventValue;
}
};

private?long?_replicatorCount?=?0L;
//?用來驗證備份線程看到了所有生產線程產生的事件
private?int?_replicatorValueSum?=?0;
//?將事件發(fā)送到備份服務器保存的備份線程
final?EventHandler?_replicator?=?new?EventHandler()?{
public?void?onEvent(final?TicketEvent?event?final?long?sequence
final?boolean?endOfBatch)?throws?Exception?{
_replicatorCount++;
_replicatorValueSum?+=?event.getValue();
}
};

final?EventHandler?_eventProcessor?=?new?EventHandler()?{
public?void?onEvent(final?TicketEvent?event?final?long?sequence
final?boolean?endOfBatch)?throws?Exception?{
System.out.println(“[processor]?====“
+?Thread.currentThread().getName()?+?“===>“
+?sequence);
}
};

private?int?RING_SIZE?=?128;
private?final?ExecutorService?EXECUTOR?=?Executors.newCachedThreadPool();

@Before
public?void?setUp()?throws?Exception?{
_journalistCount?=?_replicatorCount?=?_lastEventValue?=?0;
}

@Test
public?void?demo()?throws?Exception?{
演示disruptor的基本用法();
}


private?void?演示disruptor的基本用法()?throws?Exception?{
RingBuffer?ringBuffer?=?new?RingBuffer
TicketPoolService.INSTANCE?new?MultiThreadedClaimStrategy(
RING_SIZE)?new?YieldingWaitStrategy());

SequenceBarrier?barrier?=?ringBuffer.newBarrier();
System.err.println(Thread.currentThread().getName());
// //?注冊日志線程
// BatchEventProcessor?journalist?=?new?BatchEventProcessor
// ringBuffer?barrier?_journalist);
// ringBuffer.setGatingSequences(journalist.getSequence());
// EXECUTOR.submit(journalist);
//
// //?注冊備份線程
// BatchEventProcessor?replicator?=?new?BatchEventProcessor
// ringBuffer?barrier?_replicator);
// ringBuffer.setGatingSequences(replicator.getSequence());
// EXECUTOR.

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????5553??2013-04-10?09:51??DisruptorConceptProofTest.java
?????文件?????????344??2013-04-10?09:22??TicketEvent.java
?????文件??????????72??2013-04-10?09:23??TicketEventType.java
?????文件?????????354??2013-04-10?09:23??TicketPoolService.java
?????目錄???????????0??2013-04-09?18:21??api\
?????目錄???????????0??2012-08-22?06:51??api\meta-INF\
?????文件?????????106??2012-08-22?06:51??api\meta-INF\MANIFEST.MF
?????文件????????6464??2012-08-22?06:51??api\allclasses-frame.html
?????文件????????5624??2012-08-22?06:51??api\allclasses-noframe.html
?????目錄???????????0??2012-08-22?06:51??api\com\
?????目錄???????????0??2012-08-22?06:51??api\com\lmax\
?????目錄???????????0??2012-08-22?06:51??api\com\lmax\disruptor\
?????文件???????23192??2012-08-22?06:51??api\com\lmax\disruptor\AbstractMultithreadedClaimStrategy.html
?????文件???????15975??2012-08-22?06:51??api\com\lmax\disruptor\AggregateEventHandler.html
?????文件???????11771??2012-08-22?06:51??api\com\lmax\disruptor\AlertException.html
?????文件???????10038??2012-08-22?06:51??api\com\lmax\disruptor\BatchDescriptor.html
?????文件???????18734??2012-08-22?06:51??api\com\lmax\disruptor\BatchEventProcessor.html
?????文件???????17919??2012-08-22?06:51??api\com\lmax\disruptor\BlockingWaitStrategy.html
?????文件???????17964??2012-08-22?06:51??api\com\lmax\disruptor\BusySpinWaitStrategy.html
?????文件???????18375??2012-08-22?06:51??api\com\lmax\disruptor\ClaimStrategy.html
?????文件????????8528??2012-08-22?06:51??api\com\lmax\disruptor\EventFactory.html
?????文件???????10389??2012-08-22?06:51??api\com\lmax\disruptor\EventHandler.html
?????文件???????11037??2012-08-22?06:51??api\com\lmax\disruptor\EventProcessor.html
?????文件???????13223??2012-08-22?06:51??api\com\lmax\disruptor\EventPublisher.html
?????文件????????9029??2012-08-22?06:51??api\com\lmax\disruptor\EventTranslator.html
?????文件???????11700??2012-08-22?06:51??api\com\lmax\disruptor\ExceptionHandler.html
?????文件???????15749??2012-08-22?06:51??api\com\lmax\disruptor\FatalExceptionHandler.html
?????文件???????15730??2012-08-22?06:51??api\com\lmax\disruptor\IgnoreExceptionHandler.html
?????文件???????11340??2012-08-22?06:51??api\com\lmax\disruptor\InsufficientCapacityException.html
?????文件????????9107??2012-08-22?06:51??api\com\lmax\disruptor\LifecycleAware.html
?????文件???????17268??2012-08-22?06:51??api\com\lmax\disruptor\MultiThreadedClaimStrategy.html
............此處省略104個文件信息

評論

共有 條評論