一、handlerA必需要在handlerB前執行 java
dw.handleEventsWith(A).then(B); ide
二、handlerA必須在handlerB前執行 spa
dw.after(A).handleEventsWith(B); orm
三、舉例:註冊handler1,handler2,而且配置handlerWithBarrier在handler1,handler2執行完成後執行 對象
disruptor.handleEventsWith(handler1, handler2);
disruptor.after(handler1, handler2).handleEventsWith(handlerWithBarrier); 接口
四、舉例:註冊handler1,handler2,而且配置handlerWithBarrier在handler1,handler2執行完成後執行。handler1和handler2能夠經過and註冊到同一個group hash
disruptor.handleEventsWith(handler1);
final EventHandlerGroup<TestEvent> handler2Group = disruptor.handleEventsWith(handler2);
disruptor.after(handler1).and(handler2Group).handleEventsWith(handlerWithBarrier); it
五、舉例:調用after配置執行順序時,須要先經過handleEventsWith註冊到Disruptor io
@Test(expected = IllegalArgumentException.class) table
public void shouldThrowExceptionIfHandlerIsNotAlreadyConsuming()}
六、舉例:EvilEqualsEventHandler重寫了equals和hashCode方法,下述的handler1和handler2具備相同的equals和hashCode返回值。可是Disruptor內部的handlers的註冊時經過IdentityHashMap存儲的,也就是根據對象的引用是否相等來判斷是否已註冊,而非對象是否相等。
@Test(expected = IllegalArgumentException.class)}
--->>
java.util.IdentityHashMap<K, V>
This class implements the Map interface with a hash table, using reference-equality in place of object-equality when comparing keys (and values). In other words, in an IdentityHashMap, two keys k1 and k2 are considered equal if and only if (k1==k2). (In normal Map implementations (like HashMap) two keys k1 and k2 are considered equal if and only if (k1==null ? k2==null : k1.equals(k2)).)
大體的意思是該類也是實現了Map接口,可是比較鍵值時使用reference-equality替代了object-equality比較的方法。只有當k1==k2才被認爲是相同鍵值。普通的實現了Map接口的鍵值比較相同時是經過k1==null ? k2==null : k1.equals(k2)來確認的。