18luck򲻿

ٷҲdisruptorArrayBlockingQueueڲͬӦó˶ԱȣгһݣPproducerCconsumerABSArrayBlockingQueueĹٷܲPerformanceResultsLMAX-Exchange/disruptorWikiԿܲԵĴѾdisruptorĴУȫgitԼϲһ¿https://github.com/LMAX-Exchange/disruptor/wiki/Performance-Resultsʹõߣ//disruptor¼ͼӦ¼privateclassLongEvent{????privatelongvalue;?????????publicLongEvent(){??????this.value=0L;????}?????????publicvoidset(longvalue){??????this.value=value;????}?????????publiclongget(){??????returnthis.value;????}??}privateEventFactoryeventFactory=newEventFactory(){????????publicLongEventnewInstance(){??????returnnewLongEvent();????}};//disruptorprivateintringBufferSize=1024;privateExecutorexecutor=Executors.newFixedThreadPool(8);privateDisruptordisruptor=newDisruptor(eventFactory,ringBufferSize,executor);?//pubisher߼ԭʼתΪeventpublishringbufferprivateclassPublisherimplementsEventTranslatorOneArg{?????publicvoidtranslateTo(LongEventevent,longsequence,Stringarg0){??????event.set(Long.parseLong(arg0));????}??????}//consumer߼ȡeventдprivateclassConsumerimplementsEventHandler{?????publicvoidonEvent(LongEventevent,longsequence,booleanendOfBatch)throwsException{??????longvalue=event.get();????????????intindex=(int)(value%Const.NUM_OF_FILE);??????fileWriter[index].write(""+value+"\n");?????????????if(value==Long.MAX_VALUE){????????isFinish=true;??????}????}???????}//עconsumerdisruptordisruptor.handleEventsWith(newConsumer());disruptor.start();?//ȡdisruptorringbufferprivateRingBufferringBuffer=disruptor.getRingBuffer();ringBuffer.publishEvent(newPublisher(),line);߶ߵĸĶԼ򵥣ֻ轫disruptorһ캯ɣǶringbufferĴ߼ȫֻͬЩͬʹ͸Ľں۵ߣringbuffer߼IJͬprivateDisruptordisruptor1=newDisruptor(eventFactory,ringBufferSize,executor,ProducerType.MULTI,newBlockingWaitStrategy());߶ߵΪࣺ㲥ڶߣÿϢﵽеߣδһÿҵ߼ͨͬһϢIJͬҵ߼飺ͬһڵĶߣÿϢֻᱻһߴÿҵ߼һͬڶ߲һϢ㲥֮ϵĿǰhandler1handler2handler3ߴһϢÿϢҪߴϵʾdisruptor.handleEventsWith(handler1,handler2,handler3);֮ϵhandler3handler1handler2ɺдdisruptor.handleEventsWith(handler1,handler2).then(handler3);ΪϷ΢ͬߣҪʵWorkHandlerEventHandlerڶֱʾpublicinterfaceEventHandler{??/**???*Calledwhenapublisherhaspublishedaneventtothe{@linkRingBuffer}???*???*@paramevent???publishedtothe{@linkRingBuffer}???*@paramsequence??oftheeventbeingprocessed???*@paramendOfBatchflagtoindicateifthisisthelasteventinabatchfromthe{@linkRingBuffer}???*@throwsExceptioniftheEventHandlerwouldliketheexceptionhandledfurtherupthechain.???*/??voidonEvent(Tevent,longsequence,booleanendOfBatch)throwsException;}publicinterfaceWorkHandler{??/**???*Callbacktoindicateaunitofworkneedstobeprocessed.???*???*@parameventpublishedtothe{@linkRingBuffer}???*@throwsExceptionifthe{@linkWorkHandler}wouldliketheexceptionhandledfurtherupthechain.???*/??voidonEvent(Tevent)throwsException;}handler1handler2handler3ʵWorkHandler´Ϳʵַdisruptor.handleEventsWithWorkerPool(handler1,handler2,handler3);㲥ͷ֮ҲǿϵtipsdisruptorҲṩ˺Զ֮ĹϵpublicEventHandlerGrouphandleEventsWith(finalEventProcessorprocessors)Ȼdisruptor㹻˽ȷEventProcessorʵֶȷ߼ʵԭΪθЧ¼ԤڶdisruptorʱҪָ¼EventFactory߼disruptorڲringbufferݽṹ飬EventFactorydisruptorʼʱÿԪص䡣õӰһӴijDZȥͯȱʧĶDZǰȫģǮийпģа飬ԼǸףվ˺󡱵ԱġJBNϲijࣺۡ

地区分类  -  地区不限

更多地区

按职位发布数量标示颜色,数量越大颜色越深。
点击相应省份查看地区职位详情。

一流大学建设高校

点击加载更多>>

合作伙伴友情链接

教育部 神州学人 千人计划 教育部科技发展中心 人力资源和社会保障部 海外高层次人才 中国就业网 全日本中国人博士协会

广告合作:赵佳+86-13810238612E-mail:zhaojia@eol.cn

内容合作:肖琳+86-10-82159101-8083E-mail:xiaol@eol.cn