You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vk...@apache.org on 2015/02/02 04:28:09 UTC

[17/52] [abbrv] incubator-ignite git commit: IGNITE-146 (remove async instance caching inside Async support adapter and always create new instance)

IGNITE-146 (remove async instance caching inside Async support adapter and always create new instance)


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

Branch: refs/heads/ignite-61
Commit: 25fb8e5ca42d8137c37ce513868bd246a5cc146a
Parents: fc768b8
Author: sevdokimov <se...@gridgain.com>
Authored: Thu Jan 29 13:05:20 2015 +0300
Committer: sevdokimov <se...@gridgain.com>
Committed: Thu Jan 29 17:22:35 2015 +0300

----------------------------------------------------------------------
 .../ignite/lang/IgniteAsyncSupportAdapter.java  | 27 +++-----------------
 1 file changed, 4 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25fb8e5c/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupportAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupportAdapter.java b/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupportAdapter.java
index e9ab2a1..3d8e14c 100644
--- a/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupportAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupportAdapter.java
@@ -24,15 +24,9 @@ import org.apache.ignite.internal.*;
  * Adapter for {@link IgniteAsyncSupport}.
  */
 public class IgniteAsyncSupportAdapter<T extends IgniteAsyncSupport> implements IgniteAsyncSupport {
-    /** */
-    private static final Object mux = new Object();
-
     /** Future for previous asynchronous operation. */
     protected ThreadLocal<IgniteInternalFuture<?>> curFut;
 
-    /** */
-    private volatile T asyncInstance;
-
     /**
      * Default constructor.
      */
@@ -44,29 +38,16 @@ public class IgniteAsyncSupportAdapter<T extends IgniteAsyncSupport> implements
      * @param async Async enabled flag.
      */
     public IgniteAsyncSupportAdapter(boolean async) {
-        if (async) {
+        if (async)
             curFut = new ThreadLocal<>();
-
-            asyncInstance = (T)this;
-        }
     }
 
     /** {@inheritDoc} */
     @Override public T withAsync() {
-        T res = asyncInstance;
-
-        if (res == null) {
-            res = createAsyncInstance();
-
-            synchronized (mux) {
-                if (asyncInstance != null)
-                    return asyncInstance;
-
-                asyncInstance = res;
-            }
-        }
+        if (isAsync())
+            return (T)this;
 
-        return res;
+        return createAsyncInstance();
     }
 
     /**