首页 > 技术文章 > Disruptor LMAX学习

vigarbuaa 2013-10-11 21:56 原文

http://lmax-exchange.github.io/disruptor/

http://bruce008.iteye.com/blog/1408075

http://code.google.com/p/disruptor/wiki/CodeExampleDisruptor2x

http://www.symphonious.net/2011/07/11/lmax-disruptor-high-performance-low-latency-and-simple-too/

http://huangyunbin.iteye.com/category/287815  --系列文章

 http://ifeve.com/dissecting-disruptor-whats-so-special/

 

生成者和Disruptor关联起来. 
生成者是要首先占位置的,这个位置是通过ringBuffer的next实现的. 
生成者ok之后是通过ringBuffer的publish标志那个位置对于消费者可用的. 
而ringBuffer的产生就是由Disruptor的start生成的. 


消费者和Disruptor关联起来. 
首先消费者必须告诉Disruptor如何处理生产者留下了来的任务.说白了就是定义个有onEvent方法的EventHandler类.Disruptor通过handleEventsWith方法来接受EventHandler类. 

在Disruptor中sequencer是生产者,consumer是消费者.表示位置信息的类是Sequence 
这个时候生成者和消费者看上去 是没有关系的,但是他们都和Disruptor有关系.来看看Disruptor是如何做桥梁的吧. 
生成者和消费者要的都只是对方的位置信息. 

生成者获取消费者的位置信息 
消费者的信息都会写到Disruptor的consumerRepository中去,[/size] 

推荐阅读