简体   繁体   中英

How to find max element in array using LMAX disruptor

您能否提供有关使用 LMAX Disruptor 模式实现并行排序或并行最大查找的代码示例的链接。

It's not really applicable. The disruptor is essentially behaving like a pipe with a handler visiting every item in isolation, but it's implemented very differently for avoiding locks and improving locality of references.

To find the max, this handler would have to "leak" information in a central place, thus colliding with other threads trying to produce their own value. To sort, I wouldn't even know where to begin... you want each handler to do some insertion sort into separate array somewhere else and merge later? That's just so not a good fit.

Besides, some thread has to put the data in the ring, which is pretty much the linear search you could have done in the first place. If the ring could be built directly over an existing array (to skip publishing), then what's the point of the disruptor? You would be better off with a bunch of threads given a sub range of the array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM