Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / derby-10.3.2.1 / java / engine / org / apache / derby / impl / services / cache / ClockFactory.java
diff --git a/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/services/cache/ClockFactory.java b/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/services/cache/ClockFactory.java
new file mode 100644 (file)
index 0000000..c11933b
--- /dev/null
@@ -0,0 +1,74 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.services.cache.ClockFactory\r
+\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to you under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.services.cache;\r
+\r
+import org.apache.derby.iapi.services.cache.CacheFactory;\r
+import org.apache.derby.iapi.services.cache.CacheManager;\r
+import org.apache.derby.iapi.services.cache.Cacheable;\r
+import org.apache.derby.iapi.services.cache.CacheableFactory;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+\r
+import java.util.Properties;\r
+\r
+/**\r
+  Multithreading considerations: no need to be MT-safe, caller (module control)\r
+  provides synchronization. Besides, this class is stateless.\r
+*/\r
+\r
+public class ClockFactory implements CacheFactory {\r
+\r
+       /**\r
+               Trace flag to display cache statistics\r
+       */\r
+       public static final String CacheTrace = SanityManager.DEBUG ? "CacheTrace" : null;\r
+\r
+       public ClockFactory() {\r
+       }\r
+\r
+\r
+\r
+       /*\r
+       ** Methods of CacheFactory\r
+       */\r
+\r
+       public CacheManager newCacheManager(CacheableFactory holderFactory, String name, int initialSize, int maximumSize)\r
+       {\r
+\r
+               if (initialSize <= 0)\r
+                       initialSize = 1;\r
+\r
+               return new Clock(holderFactory, name, initialSize, maximumSize, false);\r
+       }\r
+       \r
+       public CacheManager newSizedCacheManager(CacheableFactory holderFactory, String name,\r
+                                                                               int initialSize, long maximumSize)\r
+       {\r
+\r
+               if (initialSize <= 0)\r
+                       initialSize = 1;\r
+\r
+               return new Clock(holderFactory, name, initialSize, maximumSize, true);\r
+       }\r
+}\r