Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9abf5e1d
提交
9abf5e1d
authored
10 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A concurrent list, to replace the array list of old roots.
上级
1f9fcba2
master
noel-pr1
plus33-master
pr/267
stumc-Issue#576
version-1.4.198
version-1.4.197
version-1.4.196
version-1.4.195
version-1.4.194
version-1.4.193
version-1.4.192
version-1.4.191
version-1.4.190
version-1.4.188
version-1.4.187
version-1.4.186
version-1.4.185
version-1.4.184
version-1.4.183
version-1.4.182
version-1.4.181
无相关合并请求
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
110 行增加
和
125 行删除
+110
-125
ConcurrentArrayList.java
h2/src/main/org/h2/mvstore/ConcurrentArrayList.java
+98
-117
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+2
-2
TestConcurrentLinkedList.java
h2/src/test/org/h2/test/store/TestConcurrentLinkedList.java
+7
-5
ConcurrentLinkedList.java
h2/src/tools/org/h2/dev/util/ConcurrentLinkedList.java
+3
-1
没有找到文件。
h2/src/main/org/h2/mvstore/ConcurrentArrayList.java
浏览文件 @
9abf5e1d
...
@@ -17,122 +17,103 @@ import java.util.Iterator;
...
@@ -17,122 +17,103 @@ import java.util.Iterator;
*/
*/
public
class
ConcurrentArrayList
<
K
>
{
public
class
ConcurrentArrayList
<
K
>
{
// /**
/**
// * The list.
* The array.
// */
*/
// volatile List<K> list = new List<K>(null, 0, 0);
@SuppressWarnings
(
"unchecked"
)
//
K
[]
array
=
(
K
[])
new
Object
[
0
];
// /**
// * Get the first element, or null if none.
/**
// *
* Get the first element, or null if none.
// * @return the first element
*
// */
* @return the first element
// public K peekFirst() {
*/
// return list.peekFirst();
public
K
peekFirst
()
{
// }
K
[]
a
=
array
;
//
return
a
.
length
==
0
?
null
:
a
[
0
];
// /**
}
// * Get the last element, or null if none.
// *
/**
// * @return the last element
* Get the last element, or null if none.
// */
*
// public K peekLast() {
* @return the last element
// return list.peekLast();
*/
// }
public
K
peekLast
()
{
//
K
[]
a
=
array
;
// /**
int
len
=
a
.
length
;
// * Add an element at the end.
return
len
==
0
?
null
:
a
[
len
-
1
];
// *
}
// * @param obj the element
// */
/**
// public synchronized void add(K obj) {
* Add an element at the end.
// K[] array = new K[list.length + 1];
*
// if (list.length > 0) {
* @param obj the element
// System.arraycopy(list.list, list.offset, dest, destPos, length)
*/
// Arrays.copyOf(, newLength)
public
synchronized
void
add
(
K
obj
)
{
// list = new List<K>(list.add(obj);
int
len
=
array
.
length
;
// }
array
=
Arrays
.
copyOf
(
array
,
len
+
1
);
//
array
[
len
]
=
obj
;
// /**
}
// * Remove the first element, if it matches.
// *
/**
// * @param obj the element to remove
* Remove the first element, if it matches.
// * @return true if the element matched and was removed
*
// */
* @param obj the element to remove
// public synchronized boolean removeFirst(K obj) {
* @return true if the element matched and was removed
// if (head.obj != obj) {
*/
// return false;
public
synchronized
boolean
removeFirst
(
K
obj
)
{
// }
if
(
peekFirst
()
!=
obj
)
{
// head = head.next;
return
false
;
// return true;
}
// }
int
len
=
array
.
length
;
//
@SuppressWarnings
(
"unchecked"
)
// /**
K
[]
a
=
(
K
[])
new
Object
[
len
-
1
];
// * Remove the last element, if it matches.
System
.
arraycopy
(
array
,
1
,
a
,
0
,
len
-
1
);
// *
array
=
a
;
// * @param obj the element to remove
return
true
;
// * @return true if the element matched and was removed
}
// */
// public synchronized boolean removeLast(K obj) {
/**
// if (peekLast() != obj) {
* Remove the last element, if it matches.
// return false;
*
// }
* @param obj the element to remove
// head = Entry.removeLast(head);
* @return true if the element matched and was removed
// return true;
*/
// }
public
synchronized
boolean
removeLast
(
K
obj
)
{
//
if
(
peekLast
()
!=
obj
)
{
// /**
return
false
;
// * Get an iterator over all entries.
}
// *
array
=
Arrays
.
copyOf
(
array
,
array
.
length
-
1
);
// * @return the iterator
return
true
;
// */
}
// public Iterator<K> iterator() {
// return new Iterator<K>() {
/**
//
* Get an iterator over all entries.
// List<K> list = head;
*
//
* @return the iterator
// @Override
*/
// public boolean hasNext() {
public
Iterator
<
K
>
iterator
()
{
// return current != NULL;
return
new
Iterator
<
K
>()
{
// }
//
K
[]
a
=
array
;
// @Override
int
index
;
// public K next() {
// K x = current.obj;
@Override
// current = current.next;
public
boolean
hasNext
()
{
// return x;
return
index
<
a
.
length
;
// }
}
//
// @Override
@Override
// public void remove() {
public
K
next
()
{
// throw DataUtils.newUnsupportedOperationException("remove");
return
a
[
index
++];
// }
}
//
// };
@Override
// }
public
void
remove
()
{
//
throw
DataUtils
.
newUnsupportedOperationException
(
"remove"
);
// /**
}
// * An entry in the linked list.
// */
};
// private static class List<K> {
}
// final K[] list;
// final int offset;
// final int length;
//
// List(K[] list, int offset, int length) {
// this.list = list;
// this.offset = offset;
// this.length = length;
// }
//
// public K peekFirst() {
// return length == 0 ? null : list[offset];
// }
//
// public K peekLast() {
// return length == 0 ? null : list[offset + length - 1];
// }
//
// }
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
9abf5e1d
...
@@ -53,8 +53,8 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -53,8 +53,8 @@ public class MVMap<K, V> extends AbstractMap<K, V>
private
final
DataType
keyType
;
private
final
DataType
keyType
;
private
final
DataType
valueType
;
private
final
DataType
valueType
;
private
Concurrent
Linked
List
<
Page
>
oldRoots
=
private
Concurrent
Array
List
<
Page
>
oldRoots
=
new
Concurrent
Linked
List
<
Page
>();
new
Concurrent
Array
List
<
Page
>();
private
boolean
closed
;
private
boolean
closed
;
private
boolean
readOnly
;
private
boolean
readOnly
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/store/TestConcurrentLinkedList.java
浏览文件 @
9abf5e1d
...
@@ -10,7 +10,7 @@ import java.util.LinkedList;
...
@@ -10,7 +10,7 @@ import java.util.LinkedList;
import
java.util.Random
;
import
java.util.Random
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
org.h2.mvstore.Concurrent
Linked
List
;
import
org.h2.mvstore.Concurrent
Array
List
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.util.Task
;
import
org.h2.util.Task
;
...
@@ -48,8 +48,10 @@ public class TestConcurrentLinkedList extends TestBase {
...
@@ -48,8 +48,10 @@ public class TestConcurrentLinkedList extends TestBase {
private
void
testPerformance
(
final
boolean
stock
)
{
private
void
testPerformance
(
final
boolean
stock
)
{
System
.
out
.
print
(
stock
?
"stock "
:
"custom "
);
System
.
out
.
print
(
stock
?
"stock "
:
"custom "
);
long
start
=
System
.
currentTimeMillis
();
long
start
=
System
.
currentTimeMillis
();
final
ConcurrentLinkedList
<
Integer
>
test
=
new
ConcurrentLinkedList
<
Integer
>();
// final ConcurrentLinkedList<Integer> test =
// final ConcurrentRing<Integer> test = new ConcurrentRing<Integer>();
// new ConcurrentLinkedList<Integer>();
final
ConcurrentArrayList
<
Integer
>
test
=
new
ConcurrentArrayList
<
Integer
>();
final
LinkedList
<
Integer
>
x
=
new
LinkedList
<
Integer
>();
final
LinkedList
<
Integer
>
x
=
new
LinkedList
<
Integer
>();
final
AtomicInteger
counter
=
new
AtomicInteger
();
final
AtomicInteger
counter
=
new
AtomicInteger
();
Task
task
=
new
Task
()
{
Task
task
=
new
Task
()
{
...
@@ -107,7 +109,7 @@ public class TestConcurrentLinkedList extends TestBase {
...
@@ -107,7 +109,7 @@ public class TestConcurrentLinkedList extends TestBase {
}
}
private
void
testConcurrent
()
{
private
void
testConcurrent
()
{
final
Concurrent
LinkedList
<
Integer
>
test
=
new
ConcurrentLinked
List
<
Integer
>();
final
Concurrent
ArrayList
<
Integer
>
test
=
new
ConcurrentArray
List
<
Integer
>();
// final ConcurrentRing<Integer> test = new ConcurrentRing<Integer>();
// final ConcurrentRing<Integer> test = new ConcurrentRing<Integer>();
final
AtomicInteger
counter
=
new
AtomicInteger
();
final
AtomicInteger
counter
=
new
AtomicInteger
();
final
AtomicInteger
size
=
new
AtomicInteger
();
final
AtomicInteger
size
=
new
AtomicInteger
();
...
@@ -140,7 +142,7 @@ public class TestConcurrentLinkedList extends TestBase {
...
@@ -140,7 +142,7 @@ public class TestConcurrentLinkedList extends TestBase {
private
void
testRandomized
()
{
private
void
testRandomized
()
{
Random
r
=
new
Random
(
0
);
Random
r
=
new
Random
(
0
);
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
Concurrent
LinkedList
<
Integer
>
test
=
new
ConcurrentLinked
List
<
Integer
>();
Concurrent
ArrayList
<
Integer
>
test
=
new
ConcurrentArray
List
<
Integer
>();
// ConcurrentRing<Integer> test = new ConcurrentRing<Integer>();
// ConcurrentRing<Integer> test = new ConcurrentRing<Integer>();
LinkedList
<
Integer
>
x
=
new
LinkedList
<
Integer
>();
LinkedList
<
Integer
>
x
=
new
LinkedList
<
Integer
>();
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/
main/org/h2/mvstore
/ConcurrentLinkedList.java
→
h2/src/
tools/org/h2/dev/util
/ConcurrentLinkedList.java
浏览文件 @
9abf5e1d
...
@@ -3,10 +3,12 @@
...
@@ -3,10 +3,12 @@
* and the EPL 1.0 (http://h2database.com/html/license.html).
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
* Initial Developer: H2 Group
*/
*/
package
org
.
h2
.
mvstore
;
package
org
.
h2
.
dev
.
util
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
org.h2.mvstore.DataUtils
;
/**
/**
* A very simple linked list that supports concurrent access.
* A very simple linked list that supports concurrent access.
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论