Boeing Simulation 3.1 API Specification

util
Class SinglePermitMap

java.lang.Object
  |
  +--util.SinglePermitMap

public class SinglePermitMap
extends Object

A map class that allows for multiple threads access to objects but maintains that one thread will have access at a time. Threads that request an object that is currently being used will block until the object permit has been released.

Version:
$Revision: 1.5 $
Author:
David Jurgens

Field Summary
private static Boolean AVAILABLE
           
private  Map lockedObjects
          Map containing the set of keys and values.
private static Boolean NOT_AVAILABLE
           
private  Map permitStatus
          Map containing information regarding whether an object is currently released on permit.
private  Map waitQueues
          Map containing ordered wait queues for threads requesting an object.
 
Constructor Summary
SinglePermitMap()
           
 
Method Summary
 Object acquire(Object key)
          Returns the the value if no other Thread currently has it, or blocks until the access is allowed.
 Object acquireNonBlocking(Object key)
          Returns the the value if no other Thread currently has it, or if the object is currently locked, returns null immediately rather than waiting for the value to be released.
 boolean isEmpty()
           
 Set keySet()
           
 Object put(Object key, Object value)
           
 void release(Object key)
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AVAILABLE

private static final Boolean AVAILABLE

NOT_AVAILABLE

private static final Boolean NOT_AVAILABLE

lockedObjects

private final Map lockedObjects
Map containing the set of keys and values.


permitStatus

private final Map permitStatus
Map containing information regarding whether an object is currently released on permit.


waitQueues

private final Map waitQueues
Map containing ordered wait queues for threads requesting an object.

Constructor Detail

SinglePermitMap

public SinglePermitMap()
Method Detail

acquire

public Object acquire(Object key)
Returns the the value if no other Thread currently has it, or blocks until the access is allowed. Blocking threads are notified in order of call. If the value has not been put into the map, null is immediately returned.


acquireNonBlocking

public Object acquireNonBlocking(Object key)
Returns the the value if no other Thread currently has it, or if the object is currently locked, returns null immediately rather than waiting for the value to be released.


isEmpty

public boolean isEmpty()

keySet

public Set keySet()

put

public Object put(Object key,
                  Object value)

release

public void release(Object key)

size

public int size()

Boeing Simulation 3.1 API Specification

To submit a bug or feature email the author of that class. Funding for this research was provided by Boeing and DARPA.