You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2017/12/09 14:07:31 UTC
[3/6] groovy git commit: Rename EvictableMemoizeCache to
EvictableCache
Rename EvictableMemoizeCache to EvictableCache
(cherry picked from commit 8587703)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/c43773a9
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/c43773a9
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/c43773a9
Branch: refs/heads/GROOVY_2_6_X
Commit: c43773a9d280b26d17cdcd9e466f22db507c7328
Parents: a98c342
Author: sunlan <su...@apache.org>
Authored: Sat Dec 9 20:37:33 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Sat Dec 9 22:06:47 2017 +0800
----------------------------------------------------------------------
src/main/groovy/lang/GroovyClassLoader.java | 4 +-
.../groovy/runtime/memoize/EvictableCache.java | 68 ++++++++++++++++++++
.../runtime/memoize/EvictableMemoizeCache.java | 68 --------------------
.../groovy/runtime/memoize/SimpleCache.java | 2 +-
4 files changed, 71 insertions(+), 71 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/c43773a9/src/main/groovy/lang/GroovyClassLoader.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/GroovyClassLoader.java b/src/main/groovy/lang/GroovyClassLoader.java
index 601a494..134d887 100644
--- a/src/main/groovy/lang/GroovyClassLoader.java
+++ b/src/main/groovy/lang/GroovyClassLoader.java
@@ -43,7 +43,7 @@ import org.codehaus.groovy.control.Phases;
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.runtime.IOGroovyMethods;
import org.codehaus.groovy.runtime.InvokerHelper;
-import org.codehaus.groovy.runtime.memoize.EvictableMemoizeCache;
+import org.codehaus.groovy.runtime.memoize.EvictableCache;
import org.codehaus.groovy.runtime.memoize.SimpleCache;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
@@ -321,7 +321,7 @@ public class GroovyClassLoader extends URLClassLoader {
public Class parseClass(final GroovyCodeSource codeSource, boolean shouldCacheSource) throws CompilationFailedException {
return sourceCache.getAndPut(
codeSource.getName(),
- new EvictableMemoizeCache.ValueProvider<String, Class>() {
+ new EvictableCache.ValueProvider<String, Class>() {
@Override
public Class provide(String key) {
return doParseClass(codeSource);
http://git-wip-us.apache.org/repos/asf/groovy/blob/c43773a9/src/main/org/codehaus/groovy/runtime/memoize/EvictableCache.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/memoize/EvictableCache.java b/src/main/org/codehaus/groovy/runtime/memoize/EvictableCache.java
new file mode 100644
index 0000000..369d525
--- /dev/null
+++ b/src/main/org/codehaus/groovy/runtime/memoize/EvictableCache.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.codehaus.groovy.runtime.memoize;
+
+import java.util.Collection;
+
+/**
+ * Represents an evictable memoize cache with its essential methods
+ * @param <K> type of the keys
+ * @param <V> type of the values
+ */
+public interface EvictableCache<K, V> extends MemoizeCache<K, V> {
+ /**
+ * Remove the cached value by the key
+ * @param key
+ * @return returns the removed value
+ */
+ V remove(K key);
+
+ /**
+ * Clear the cache
+ * @return returns cleared values
+ */
+ Collection<V> clear();
+
+ /**
+ * Try to get the value from cache.
+ * If not found, create the value by {@link ValueProvider} and put it into the cache, at last return the value
+ * @param key
+ * @return the cached value
+ */
+ V getAndPut(K key, ValueProvider<K, V> valueProvider);
+
+ /**
+ * Get all cached values
+ * @return all cached values
+ */
+ Collection<V> values();
+
+ /**
+ * Represents a provider used to create value
+ * @param <K> type of the key
+ * @param <V> type of the value
+ */
+ interface ValueProvider<K, V> {
+ /**
+ * Provide the created value
+ * @return
+ */
+ V provide(K key);
+ }
+}
http://git-wip-us.apache.org/repos/asf/groovy/blob/c43773a9/src/main/org/codehaus/groovy/runtime/memoize/EvictableMemoizeCache.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/memoize/EvictableMemoizeCache.java b/src/main/org/codehaus/groovy/runtime/memoize/EvictableMemoizeCache.java
deleted file mode 100644
index a5dd318..0000000
--- a/src/main/org/codehaus/groovy/runtime/memoize/EvictableMemoizeCache.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.codehaus.groovy.runtime.memoize;
-
-import java.util.Collection;
-
-/**
- * Represents an evictable memoize cache with its essential methods
- * @param <K> type of the keys
- * @param <V> type of the values
- */
-public interface EvictableMemoizeCache<K, V> extends MemoizeCache<K, V> {
- /**
- * Remove the cached value by the key
- * @param key
- * @return returns the removed value
- */
- V remove(K key);
-
- /**
- * Clear the cache
- * @return returns cleared values
- */
- Collection<V> clear();
-
- /**
- * Try to get the value from cache.
- * If not found, create the value by {@link ValueProvider} and put it into the cache, at last return the value
- * @param key
- * @return the cached value
- */
- V getAndPut(K key, ValueProvider<K, V> valueProvider);
-
- /**
- * Get all cached values
- * @return all cached values
- */
- Collection<V> values();
-
- /**
- * Represents a provider used to create value
- * @param <K> type of the key
- * @param <V> type of the value
- */
- interface ValueProvider<K, V> {
- /**
- * Provide the created value
- * @return
- */
- V provide(K key);
- }
-}
http://git-wip-us.apache.org/repos/asf/groovy/blob/c43773a9/src/main/org/codehaus/groovy/runtime/memoize/SimpleCache.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/memoize/SimpleCache.java b/src/main/org/codehaus/groovy/runtime/memoize/SimpleCache.java
index 4eb0453..b789067 100644
--- a/src/main/org/codehaus/groovy/runtime/memoize/SimpleCache.java
+++ b/src/main/org/codehaus/groovy/runtime/memoize/SimpleCache.java
@@ -32,7 +32,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
* @param <K> type of the keys
* @param <V> type of the values
*/
-public class SimpleCache<K, V> implements EvictableMemoizeCache<K, V> {
+public class SimpleCache<K, V> implements EvictableCache<K, V> {
private final Map<K, V> map = new HashMap<>();
private final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();
private final ReentrantReadWriteLock.ReadLock readLock = rwl.readLock();