diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2007-03-28 22:00:24 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2007-03-28 22:00:24 +0000 |
commit | 8809341248c62b15b78d7e6d8e06ab2ec3793c8e (patch) | |
tree | f39d7353987e025758e0a3abe1ffb49a48e9be9e /src/main/java/com/amazon/carbonado/util/WeakReentrantReadWriteLockPool.java | |
parent | 65478f17ada9df04c4c2afa734378bb50ec2bd13 (diff) |
Merged 1.2-dev to trunk.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/util/WeakReentrantReadWriteLockPool.java')
-rw-r--r-- | src/main/java/com/amazon/carbonado/util/WeakReentrantReadWriteLockPool.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/util/WeakReentrantReadWriteLockPool.java b/src/main/java/com/amazon/carbonado/util/WeakReentrantReadWriteLockPool.java new file mode 100644 index 0000000..b41ad1f --- /dev/null +++ b/src/main/java/com/amazon/carbonado/util/WeakReentrantReadWriteLockPool.java @@ -0,0 +1,45 @@ +/*
+ * Copyright 2006 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. All rights reserved.
+ *
+ * Licensed 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 com.amazon.carbonado.util;
+
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * A concurrent pool of weakly referenced {@link ReentrantReadWriteLock}
+ * instances mapped by key. Locks are created (and recreated) as needed.
+ *
+ * @author Brian S O'Neill
+ */
+class WeakReentrantReadWriteLockPool<K>
+ extends AbstractWeakPool<K, ReentrantReadWriteLock, RuntimeException>
+{
+ private final boolean mFair;
+
+ public WeakReentrantReadWriteLockPool() {
+ this(false);
+ }
+
+ public WeakReentrantReadWriteLockPool(boolean fair) {
+ mFair = fair;
+ }
+
+ protected ReentrantReadWriteLock create(K key) {
+ return new ReentrantReadWriteLock(mFair);
+ }
+}
|