com.sun.jini.jeri.internal.http
Class TimedMap

java.lang.Object
  extended by com.sun.jini.jeri.internal.http.TimedMap
Direct Known Subclasses:
ConnectionTimer.TimeoutMap, HttpServerManager.AckListenerMap

 class TimedMap
extends Object

Simple hash map which evicts entries after a fixed timeout. All operations which modify a TimedMap synchronize on the TimedMap instance itself, including the thread which evicts expired entries.

Author:
Sun Microsystems, Inc.

Nested Class Summary
private  class TimedMap.Evictor
          Expired mapping eviction thread.
private static class TimedMap.Mapping
          Key/value mapping.
private static class TimedMap.Queue
          Lightweight doubly-linked queue supporting constant-time manipulation.
 
Field Summary
private  boolean evictorActive
           
private  TimedMap.Queue evictQueue
           
private  Executor executor
           
private  Map map
           
private  long timeout
           
 
Constructor Summary
TimedMap(Executor executor, long timeout)
          Creates empty TimedMap which uses threads from the given Executor to evict entries after the specified timeout.
 
Method Summary
(package private)  void evicted(Object key, Object value)
          Upcall invoked after key's timeout has expired and key has been removed from the map.
(package private)  Object get(Object key)
          Returns value associated with given key, or null if no mapping for key is found.
(package private)  Object put(Object key, Object value)
          Associates the given key with the given value, resetting the key's timeout.
(package private)  Object remove(Object key)
          Removes mapping for key from map, returning the value associated with the key (or null if no mapping present).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

executor

private final Executor executor

timeout

private final long timeout

map

private final Map map

evictQueue

private final TimedMap.Queue evictQueue

evictorActive

private boolean evictorActive
Constructor Detail

TimedMap

TimedMap(Executor executor,
         long timeout)
Creates empty TimedMap which uses threads from the given Executor to evict entries after the specified timeout.

Method Detail

put

Object put(Object key,
           Object value)
Associates the given key with the given value, resetting the key's timeout. Returns value (if any) previously associated with key.


get

Object get(Object key)
Returns value associated with given key, or null if no mapping for key is found. Resets timeout for key if it is present in map.


remove

Object remove(Object key)
Removes mapping for key from map, returning the value associated with the key (or null if no mapping present).


evicted

void evicted(Object key,
             Object value)
Upcall invoked after key's timeout has expired and key has been removed from the map.



Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.