Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
ddc002ae
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ddc002ae
编写于
4月 29, 2016
作者:
T
tvaleev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8154387: Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less
Reviewed-by: psandoz
上级
ab8cdddb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
11 addition
and
6 deletion
+11
-6
src/share/classes/java/util/stream/StreamSpliterators.java
src/share/classes/java/util/stream/StreamSpliterators.java
+11
-6
未找到文件。
src/share/classes/java/util/stream/StreamSpliterators.java
浏览文件 @
ddc002ae
...
...
@@ -28,6 +28,7 @@ import java.util.Comparator;
import
java.util.Objects
;
import
java.util.Spliterator
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ForkJoinPool
;
import
java.util.concurrent.atomic.AtomicLong
;
import
java.util.function.BooleanSupplier
;
import
java.util.function.Consumer
;
...
...
@@ -905,6 +906,7 @@ class StreamSpliterators {
// The spliterator to slice
protected
final
T_SPLITR
s
;
protected
final
boolean
unlimited
;
protected
final
int
chunkSize
;
private
final
long
skipThreshold
;
private
final
AtomicLong
permits
;
...
...
@@ -912,6 +914,8 @@ class StreamSpliterators {
this
.
s
=
s
;
this
.
unlimited
=
limit
<
0
;
this
.
skipThreshold
=
limit
>=
0
?
limit
:
0
;
this
.
chunkSize
=
limit
>=
0
?
(
int
)
Math
.
min
(
CHUNK_SIZE
,
((
skip
+
limit
)
/
AbstractTask
.
LEAF_TARGET
)
+
1
)
:
CHUNK_SIZE
;
this
.
permits
=
new
AtomicLong
(
limit
>=
0
?
skip
+
limit
:
skip
);
}
...
...
@@ -921,6 +925,7 @@ class StreamSpliterators {
this
.
unlimited
=
parent
.
unlimited
;
this
.
permits
=
parent
.
permits
;
this
.
skipThreshold
=
parent
.
skipThreshold
;
this
.
chunkSize
=
parent
.
chunkSize
;
}
/**
...
...
@@ -1029,13 +1034,13 @@ class StreamSpliterators {
PermitStatus
permitStatus
;
while
((
permitStatus
=
permitStatus
())
!=
PermitStatus
.
NO_MORE
)
{
if
(
permitStatus
==
PermitStatus
.
MAYBE_MORE
)
{
// Optimistically traverse elements up to a threshold of
CHUNK_SIZE
// Optimistically traverse elements up to a threshold of
chunkSize
if
(
sb
==
null
)
sb
=
new
ArrayBuffer
.
OfRef
<>(
CHUNK_SIZE
);
sb
=
new
ArrayBuffer
.
OfRef
<>(
chunkSize
);
else
sb
.
reset
();
long
permitsRequested
=
0
;
do
{
}
while
(
s
.
tryAdvance
(
sb
)
&&
++
permitsRequested
<
CHUNK_SIZE
);
do
{
}
while
(
s
.
tryAdvance
(
sb
)
&&
++
permitsRequested
<
chunkSize
);
if
(
permitsRequested
==
0
)
return
;
sb
.
forEach
(
action
,
acquirePermits
(
permitsRequested
));
...
...
@@ -1102,15 +1107,15 @@ class StreamSpliterators {
PermitStatus
permitStatus
;
while
((
permitStatus
=
permitStatus
())
!=
PermitStatus
.
NO_MORE
)
{
if
(
permitStatus
==
PermitStatus
.
MAYBE_MORE
)
{
// Optimistically traverse elements up to a threshold of
CHUNK_SIZE
// Optimistically traverse elements up to a threshold of
chunkSize
if
(
sb
==
null
)
sb
=
bufferCreate
(
CHUNK_SIZE
);
sb
=
bufferCreate
(
chunkSize
);
else
sb
.
reset
();
@SuppressWarnings
(
"unchecked"
)
T_CONS
sbc
=
(
T_CONS
)
sb
;
long
permitsRequested
=
0
;
do
{
}
while
(
s
.
tryAdvance
(
sbc
)
&&
++
permitsRequested
<
CHUNK_SIZE
);
do
{
}
while
(
s
.
tryAdvance
(
sbc
)
&&
++
permitsRequested
<
chunkSize
);
if
(
permitsRequested
==
0
)
return
;
sb
.
forEach
(
action
,
acquirePermits
(
permitsRequested
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录