1 /***
2 * Copyright 2003-2010 Terracotta, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package net.sf.ehcache.pool.impl;
18
19 import net.sf.ehcache.pool.PoolAccessor;
20 import net.sf.ehcache.pool.PoolEvictor;
21 import net.sf.ehcache.pool.PoolableStore;
22 import net.sf.ehcache.pool.SizeOfEngine;
23
24 /***
25 * A pool which strictly obeys to its bound: it will never allow the accessors to consume more bytes than what
26 * has been configured.
27 *
28 * @author Ludovic Orban
29 */
30 public class StrictlyBoundedPool extends AbstractPool<PoolableStore> {
31
32 /***
33 * Create a StrictlyBoundedPool instance
34 *
35 * @param maximumPoolSize the maximum size of the pool, in bytes.
36 * @param evictor the pool evictor, for cross-store eviction.
37 * @param defaultSizeOfEngine the default SizeOf engine used by the accessors.
38 */
39 public StrictlyBoundedPool(long maximumPoolSize, PoolEvictor<PoolableStore> evictor, SizeOfEngine defaultSizeOfEngine) {
40 super(maximumPoolSize, evictor, defaultSizeOfEngine);
41 }
42
43 /***
44 * {@inheritDoc}
45 */
46 public PoolAccessor createPoolAccessor(PoolableStore store, SizeOfEngine sizeOfEngine) {
47 LockedPoolAccessor accessor = new LockedPoolAccessor(this, store, sizeOfEngine, 0);
48 registerPoolAccessor(accessor);
49 return accessor;
50 }
51 }