ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [14/14] ignite git commit: Reverting changes to compound future.
Date Fri, 05 Feb 2016 12:25:50 GMT
Reverting changes to compound future.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/11c369a9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/11c369a9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/11c369a9

Branch: refs/heads/ignite-2329-1
Commit: 11c369a9337ab905b95bb73c866bf7e3d8df6a23
Parents: c66d16c
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Fri Feb 5 15:24:04 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Fri Feb 5 15:24:04 2016 +0300

----------------------------------------------------------------------
 .../util/future/GridCompoundFuture.java         | 46 ++++++++++----------
 1 file changed, 23 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/11c369a9/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
index fca8741..c382497 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
@@ -17,10 +17,6 @@
 
 package org.apache.ignite.internal.util.future;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.IgniteFutureCancelledCheckedException;
 import org.apache.ignite.internal.IgniteInternalFuture;
@@ -35,6 +31,10 @@ import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.lang.IgniteReducer;
 import org.jetbrains.annotations.Nullable;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
+
 /**
  * Future composed of multiple inner futures.
  */
@@ -54,7 +54,7 @@ public class GridCompoundFuture<T, R> extends GridFutureAdapter<R>
implements Ig
         AtomicIntegerFieldUpdater.newUpdater(GridCompoundFuture.class, "lsnrCalls");
 
     /** Futures. */
-    protected ArrayList<IgniteInternalFuture<T>> futs;
+    protected final ArrayList<IgniteInternalFuture<T>> futs = new ArrayList<>();
 
     /** Reducer. */
     @GridToStringInclude
@@ -154,8 +154,10 @@ public class GridCompoundFuture<T, R> extends GridFutureAdapter<R>
implements Ig
      *
      * @return Collection of futures.
      */
-    public synchronized Collection<IgniteInternalFuture<T>> futures() {
-        return futs == null ? Collections.<IgniteInternalFuture<T>>emptyList()
: new ArrayList<>(futs);
+    public Collection<IgniteInternalFuture<T>> futures() {
+        synchronized (futs) {
+            return new ArrayList<>(futs);
+        }
     }
 
     /**
@@ -176,16 +178,15 @@ public class GridCompoundFuture<T, R> extends GridFutureAdapter<R>
implements Ig
      * @return {@code True} if there are pending futures.
      */
     @SuppressWarnings("ForLoopReplaceableByForEach")
-    public synchronized boolean hasPending() {
-        if (futs == null)
-            return false;
-
-        // Avoid iterator creation and collection copy.
-        for (int i = 0; i < futs.size(); i++) {
-            IgniteInternalFuture<T> fut = futs.get(i);
-
-            if (!fut.isDone())
-                return true;
+    public boolean hasPending() {
+        synchronized (futs) {
+            // Avoid iterator creation and collection copy.
+            for (int i = 0; i < futs.size(); i++) {
+                IgniteInternalFuture<T> fut = futs.get(i);
+
+                if (!fut.isDone())
+                    return true;
+            }
         }
 
         return false;
@@ -199,10 +200,7 @@ public class GridCompoundFuture<T, R> extends GridFutureAdapter<R>
implements Ig
     public void add(IgniteInternalFuture<T> fut) {
         assert fut != null;
 
-        synchronized (this) {
-            if (futs == null)
-                futs = new ArrayList<>();
-
+        synchronized (futs) {
             futs.add(fut);
         }
 
@@ -260,8 +258,10 @@ public class GridCompoundFuture<T, R> extends GridFutureAdapter<R>
implements Ig
     /**
      * @return Futures size.
      */
-    protected synchronized int futuresSize() {
-        return futs == null ? 0 : futs.size();
+    private int futuresSize() {
+        synchronized (futs) {
+            return futs.size();
+        }
     }
 
     /** {@inheritDoc} */


Mime
View raw message