![](/img/trans.png)
[英]how to fulfill the ringbuffer with data from my hashmap lmax disruptor
[英](LMAX disruptor)How to get data by myself not by callback?
我了解到LMAX破壞者是一個高性能線程間消息傳遞庫。 但是當我嘗試使用它時,我發現事件處理程序使用回調方法來處理數據。
void onEvent(T event,
long sequence,
boolean endOfBatch)
throws java.lang.Exception
當發布者將事件發布到RingBuffer時調用
但是,如果我不使用回調獲取數據,我會寫一會兒(true)自行獲取數據,那我該怎么辦?
謝謝!
您應該編寫回調,以便將事件推送到隊列中。 然后,您可以遍歷隊列。
Queue<Event> queue = new ArrayBlockingQueue(10);
void onEvent(Event event,
long sequence,
boolean endOfBatch)
throws java.lang.Exception {
queue.add(event);
}
public void test() {
for ( Event event : queue ) {
// Your stuff here.
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.