You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2015/08/01 02:58:57 UTC
incubator-ignite git commit: # ignite-1159
Repository: incubator-ignite
Updated Branches:
refs/heads/master 3d9b9dfac -> 93b205758
# ignite-1159
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/93b20575
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/93b20575
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/93b20575
Branch: refs/heads/master
Commit: 93b205758fea49f415802a7007e054e95f6af2c7
Parents: 3d9b9df
Author: Alexey Goncharuk <ag...@gridgain.com>
Authored: Fri Jul 31 17:34:34 2015 -0700
Committer: Alexey Goncharuk <ag...@gridgain.com>
Committed: Fri Jul 31 17:53:18 2015 -0700
----------------------------------------------------------------------
.../processors/cache/GridCacheMvccManager.java | 73 ++++----------------
.../processors/cache/GridCacheMvccSelfTest.java | 1 -
2 files changed, 13 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/93b20575/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index a0d9051..6a8c6fe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -51,9 +51,9 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
private static final int MAX_REMOVED_LOCKS = 10240;
/** Pending locks per thread. */
- private final ThreadLocal<Queue<GridCacheMvccCandidate>> pending =
- new ThreadLocal<Queue<GridCacheMvccCandidate>>() {
- @Override protected Queue<GridCacheMvccCandidate> initialValue() {
+ private final ThreadLocal<LinkedList<GridCacheMvccCandidate>> pending =
+ new ThreadLocal<LinkedList<GridCacheMvccCandidate>>() {
+ @Override protected LinkedList<GridCacheMvccCandidate> initialValue() {
return new LinkedList<>();
}
};
@@ -708,35 +708,6 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
}
/**
- * Unlinks a lock candidate.
- *
- * @param cand Lock candidate to unlink.
- */
- private void unlink(GridCacheMvccCandidate cand) {
- GridCacheMvccCandidate next = cand.next();
-
- if (next != null) {
- GridCacheMvccCandidate prev = cand.previous();
-
- next.previous(prev);
-
- if (prev != null)
- prev.next(next);
- }
-
- /*
- * Note that we specifically don't set links from passed in
- * candidate to null because it is possible in some race
- * cases that it will get traversed. However, it should
- * still become available for GC and should not cause
- * an issue.
- */
-
- if (log.isDebugEnabled())
- log.debug("Unlinked lock candidate: " + cand);
- }
-
- /**
*
* @param cand Cache lock candidate to add.
* @return {@code True} if added as a result of this operation,
@@ -751,43 +722,25 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
if (cacheCtx.isNear() || cand.singleImplicit())
return true;
- Queue<GridCacheMvccCandidate> queue = pending.get();
-
- boolean add = true;
+ LinkedList<GridCacheMvccCandidate> queue = pending.get();
GridCacheMvccCandidate prev = null;
- for (Iterator<GridCacheMvccCandidate> it = queue.iterator(); it.hasNext(); ) {
- GridCacheMvccCandidate c = it.next();
-
- if (c.equals(cand))
- add = false;
-
- if (c.used()) {
- it.remove();
+ if (!queue.isEmpty())
+ prev = queue.getLast();
- unlink(c);
+ queue.add(cand);
- continue;
- }
+ if (prev != null) {
+ prev.next(cand);
- prev = c;
+ cand.previous(prev);
}
- if (add) {
- queue.add(cand);
-
- if (prev != null) {
- prev.next(cand);
-
- cand.previous(prev);
- }
-
- if (log.isDebugEnabled())
- log.debug("Linked new candidate: " + cand);
- }
+ if (log.isDebugEnabled())
+ log.debug("Linked new candidate: " + cand);
- return add;
+ return true;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/93b20575/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java
index be7e3c9..2a4365d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java
@@ -1387,7 +1387,6 @@ public class GridCacheMvccSelfTest extends GridCommonAbstractTest {
ctx.mvcc().addNext(ctx, c4);
- assert c3.previous() == null;
assert c4 != null;
assert c4.previous() == c3;
}