/*
* Copyright (c) 2002-2003 by OpenSymphony
* All rights reserved.
*/
/*
File: AbstractConcurrentReadCache
Written by Doug Lea. Adapted from JDK1.2 HashMap.java and Hashtable.java
which carries the following copyright:
* Copyright 1997 by Sun Microsystems, Inc.,
* 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
* All rights reserved.
*
* This software is the confidential and proprietary information
* of Sun Microsystems, Inc. ("Confidential Information"). You
* shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with Sun.
This class is a modified version of ConcurrentReaderHashMap, which was written
by Doug Lea (http://gee.cs.oswego.edu/dl/). The modifications where done
by Pyxis Technologies. This is a base class for the OSCache module of the
openSymphony project (www.opensymphony.com).
History:
Date Who What
28oct1999 dl Created
14dec1999 dl jmm snapshot
19apr2000 dl use barrierLock
12jan2001 dl public release
Oct2001 abergevin@pyxis-tech.com
Integrated persistence and outer algorithm support
*/
package com.opensymphony.oscache.base.algorithm;
/** OpenSymphony BEGIN */
import com.opensymphony.oscache.base.CacheEntry;
import com.opensymphony.oscache.base.persistence.CachePersistenceException;
import com.opensymphony.oscache.base.persistence.PersistenceListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.io.Serializable;
import java.util.*;
/**
* A version of Hashtable that supports mostly-concurrent reading, but exclusive writing.
* Because reads are not limited to periods
* without writes, a concurrent reader policy is weaker than a classic
* reader/writer policy, but is generally faster and allows more
* concurrency. This class is a good choice especially for tables that
* are mainly created by one thread during the start-up phase of a
* program, and from then on, are mainly read (with perhaps occasional
* additions or removals) in many threads. If you also need concurrency
* among writes, consider instead using ConcurrentHashMap.
* <p>
*
* Successful retrievals using get(key) and containsKey(key) usually
* run without locking. Unsuccessful ones (i.e., when the key is not
* present) do involve brief synchronization (locking). Also, the
* size and isEmpty methods are always synchronized.
*
* <p> Because retrieval operations can ordinarily overlap with
* writing operations (i.e., put, remove, and their derivatives),
* retrievals can only be guaranteed to return the results of the most
* recently <em>completed</em> operations holding upon their
* onset. Retrieval operations may or may not return results
* reflecting in-progress writing operations. However, the retrieval
* operations do always return consistent results -- either those
* holding before any single modification or after it, but never a
* nonsense result. For aggregate operations such as putAll and
* clear, concurrent reads may reflect insertion or removal of only
* some entries. In those rare contexts in which you use a hash table
* to synchronize operations across threads (for example, to prevent
* reads until after clears), you should either encase operations
* in synchronized blocks, or instead use java.util.Hashtable.
*
* <p>
*
* This class also supports optional guaranteed
* exclusive reads, simply by surrounding a call within a synchronized
* block, as in <br>
* <code>AbstractConcurrentReadCache t; ... Object v; <br>
* synchronized(t) { v = t.get(k); } </code> <br>
*
* But this is not usually necessary in practice. For
* example, it is generally inefficient to write:
*
* <pre>
* AbstractConcurrentReadCache t; ... // Inefficient version
* Object key; ...
* Object value; ...
* synchronized(t) {
* if (!t.containsKey(key))
* t.put(key, value);
* // other code if not previously present
* }
* else {
* // other code if it was previously present
* }
* }
*</pre>
* Instead, just take advantage of the fact that put returns
* null if the key was not previously present:
* <pre>
* AbstractConcurrentReadCache t; ... // Use this instead
* Object key; ...
* Object value; ...
* Object oldValue = t.put(key, value);
* if (oldValue == null) {
* // other code if not previously present
* }
* else {
* // other code if it was previously present
* }
*</pre>
* <p>
*
* Iterators and Enumerations (i.e., those returned by
* keySet().iterator(), entrySet().iterator(), values().iterator(),
* keys(), and elements()) return elements reflecting the state of the
* hash table at some point at or since the creation of the
* iterator/enumeration. They will return at most one instance of
* each element (via next()/nextElement()), but might or might not
* reflect puts and removes that have been processed since they were
* created. They do <em>not</em> throw ConcurrentModificationException.
* However, these iterators are designed to be used by only one
* thread at a time. Sharing an iterator across multiple threads may
* lead to unpredictable results if the table is being concurrently
* modified. Again, you can ensure interference-free iteration by
* enclosing the iteration in a synchronized block. <p>
*
* This class may be used as a direct replacement for any use of
* java.util.Hashtable that does not depend on readers being blocked
* during updates. Like Hashtable but unlike java.util.HashMap,
* this class does NOT allow <tt>null</tt> to be used as a key or
* value. This class is also typically faster than ConcurrentHashMap
* when there is usually only one thread updating the table, but
* possibly many retrieving values from it.
* <p>
*
* Implementation note: A slightly faster implementation of
* this class will be possible once planned Java Memory Model
* revisions are in place.
*
* <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
**/
public abstract class AbstractConcurrentReadCache extends AbstractMap implements Map, Cloneable, Serializable {
/**
* The default initial number of table slots for this table (32).
* Used when not otherwise specified in constructor.
**/
public static int DEFAULT_INITIAL_CAPACITY = 32;
/**
* The minimum capacity.
* Used if a lower value is implicitly specified
* by either of the constructors with arguments.
* MUST be a power of two.
*/
private static final int MINIMUM_CAPACITY = 4;
/**
* The maximum capacity.
* Used if a higher value is implicitly specified
* by either of the constructors with arguments.
* MUST be a power of two <= 1<<30.
*/
private static final int MAXIMUM_CAPACITY = 1 << 30;
/**
* The default load factor for this table.
* Used when not otherwise specified in constructor, the default is 0.75f.
**/
public static final float DEFAULT_LOAD_FACTOR = 0.75f;
//OpenSymphony BEGIN (pretty long!)
protected static final String NULL = "_nul!~";
protected static final transient Log log = LogFactory.getLog(AbstractConcurrentReadCache.class);
/*
The basic strategy is an optimistic-style scheme based on
the guarantee that the hash table and its lists are always
kept in a consistent enough state to be read without locking:
* Read operations first pro
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
oscache-2.0.2-full.zip (420个子文件)
style.css 4KB
api.css 1KB
api.css 1KB
stylesheet.css 960B
pyxis-box-sponsor.gif 3KB
atlassian-sponsor.gif 1KB
logo.gif 725B
inherit.gif 57B
trans.gif 43B
AbstractConcurrentReadCache.html 637KB
FastCronParser.html 337KB
Cache.html 274KB
CacheTag.html 257KB
ServletCacheAdministrator.html 243KB
index-all.html 208KB
DiskPersistenceListener.html 161KB
AbstractCacheAdministrator.html 124KB
CacheEntry.html 97KB
GeneralCacheAdministrator.html 93KB
AbstractConcurrentReadCache.html 79KB
LRUCache.html 76KB
CacheHttpServletResponseWrapper.html 69KB
JavaGroupsBroadcastingListener.html 62KB
JMS10BroadcastingListener.html 61KB
JMSBroadcastingListener.html 61KB
AbstractBroadcastingListener.html 60KB
CacheEntryEventListenerImpl.html 60KB
FlushTag.html 57KB
Cache.html 54KB
Config.html 52KB
ServletCacheAdministrator.html 52KB
CacheFilter.html 47KB
ScopeEventListenerImpl.html 46KB
ServletCache.html 40KB
serialized-form.html 38KB
EntryUpdateState.html 37KB
AbstractCacheAdministrator.html 37KB
FIFOCache.html 37KB
CacheMapAccessEventListenerImpl.html 37KB
GeneralCacheAdministrator.html 35KB
ResponseContent.html 31KB
PersistenceListener.html 31KB
CacheTag.html 30KB
LRUCache.html 29KB
UnlimitedCache.html 29KB
FIFOCache.html 29KB
ClusterNotification.html 29KB
CacheEntryEventListenerImpl.html 27KB
Cache.html 27KB
ScopeEvent.html 26KB
SplitServletOutputStream.html 26KB
CacheEntryEvent.html 26KB
CacheEntry.html 25KB
CacheHttpServletResponseWrapper.html 25KB
CacheGroupEvent.html 25KB
changelog.html 25KB
CachePatternEvent.html 24KB
CacheMapAccessEvent.html 24KB
ServletCache.html 23KB
UnlimitedCache.html 22KB
UseCachedTag.html 22KB
ScopeEventListenerImpl.html 21KB
CachewideEvent.html 21KB
PersistenceListener.html 21KB
overview-tree.html 20KB
AbstractConcurrentReadCache.HashIterator.html 20KB
constant-values.html 20KB
CacheEntryEventListener.html 19KB
CacheEntry.html 19KB
CacheEntryEventType.html 19KB
EntryUpdateState.html 18KB
AbstractConcurrentReadCache.Entry.html 18KB
ClassLoaderUtil.html 18KB
StringUtil.html 18KB
CacheEvent.html 18KB
FlushTag.html 18KB
package-use.html 18KB
CacheMapAccessEvent.html 17KB
EntryRefreshPolicy.html 17KB
CacheEntryEvent.html 17KB
package-use.html 17KB
CacheEntryEventListener.html 17KB
ScopeEvent.html 16KB
LifecycleAware.html 16KB
CachePatternEvent.html 16KB
CacheGroupEvent.html 16KB
PersistenceListener.html 16KB
CacheEventListener.html 16KB
CacheMapAccessEventListenerImpl.html 16KB
CacheContextListener.html 15KB
AbstractConcurrentReadCache.KeyIterator.html 15KB
FastCronParser.html 15KB
AbstractConcurrentReadCache.ValueIterator.html 15KB
ResponseContent.html 15KB
TestCompleteBase.html 15KB
CacheEntryEventType.html 15KB
CachewideEvent.html 15KB
Config.html 15KB
CacheEntryEvent.html 14KB
SplitServletOutputStream.html 14KB
共 420 条
- 1
- 2
- 3
- 4
- 5
资源评论
- qq_253407132016-05-04好用,谢谢
- Luoch20102014-11-05去官网下没下载下来,还是csdn靠谱
heartbeaty
- 粉丝: 54
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 5uonly.apk
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
- 基于MIC+NE555光敏电阻的声光控电路Multisim仿真原理图
- 基于JSP毕业设计-基于WEB操作系统课程教学网站的设计与实现(源代码+论文).zip
- 基于LM324和LM386的音响放大器Multisim仿真+PCB电路原理图
- Python机器学习与数据挖掘环境配置与库验证
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功