本文整理了Java中com.oath.cyclops.async.adapters.Queue.streamBatch
方法的一些代码示例,展示了Queue.streamBatch
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Queue.streamBatch
方法的具体详情如下:
包路径:com.oath.cyclops.async.adapters.Queue
类名称:Queue
方法名:streamBatch
暂无
代码示例来源:origin: aol/cyclops
public ReactiveSeq<Seq<T>> streamGroupedBySizeAndTime(int size, long time, TimeUnit t){
long toRun = t.toNanos(time);
return streamBatch(new Subscription(), source->{
return ()->{
List<T> result = new ArrayList<>();
long start = System.nanoTime();
try {
while (result.size() < size && checkTime(System.nanoTime(), start, toRun)) {
try {
T next = source.apply(100l, TimeUnit.MICROSECONDS);
if (next != null) {
result.add(next);
}
} catch (Queue.QueueTimeoutException e) {
}
}
}catch(Queue.ClosedQueueException e){
if(result.size()>0) {
List list = new ArrayList<>();
list.add(result);
throw new ClosedQueueException(list);
}
}
return result;
};
}).filter(l->l.size()>0)
.map(Seq::fromIterable);
}
代码示例来源:origin: com.oath.cyclops/cyclops
public ReactiveSeq<Seq<T>> streamGroupedBySizeAndTime(int size, long time, TimeUnit t){
long toRun = t.toNanos(time);
return streamBatch(new Subscription(), source->{
return ()->{
List<T> result = new ArrayList<>();
long start = System.nanoTime();
try {
while (result.size() < size && checkTime(System.nanoTime(), start, toRun)) {
try {
T next = source.apply(100l, TimeUnit.MICROSECONDS);
if (next != null) {
result.add(next);
}
} catch (Queue.QueueTimeoutException e) {
}
}
}catch(Queue.ClosedQueueException e){
if(result.size()>0) {
List list = new ArrayList<>();
list.add(result);
throw new ClosedQueueException(list);
}
}
return result;
};
}).filter(l->l.size()>0)
.map(Seq::fromIterable);
}
内容来源于网络,如有侵权,请联系作者删除!