Package jadex.collection
Class ActionReferenceQueue
java.lang.Object
java.lang.ref.ReferenceQueue
jadex.collection.ActionReferenceQueue
The extended reference queue allows for adding (weak)
object with an associated action. Whenever the object
becomes unreferenced its corresponding weak entry can
be fetched from the queue and when this is done the
associated action will automatically be executed.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Add an object with an associated value.int
Get the size of the entries (existing objects).poll()
Poll a stale entry.remove()
Remove an element from the queue.remove
(long timeout) Remove an element from the queue.removeEntry
(Object obj) Remove an entry.toString()
Get the string representation.
-
Field Details
-
entries
The list of elements.
-
-
Constructor Details
-
ActionReferenceQueue
public ActionReferenceQueue()Create a new list.
-
-
Method Details
-
addEntry
Add an object with an associated value.- Parameters:
o
- The object (becomes weak reference).val
- The value.
-
removeEntry
Remove an entry. -
getEntriesSize
public int getEntriesSize()Get the size of the entries (existing objects). Does not expunge stale entries.- Returns:
- The number of existing entries.
-
remove
Remove an element from the queue.- Overrides:
remove
in classReferenceQueue
- Returns:
- A weak entry.
- Throws:
InterruptedException
-
remove
Remove an element from the queue.- Overrides:
remove
in classReferenceQueue
- Returns:
- A weak entry.
- Throws:
IllegalArgumentException
InterruptedException
-
poll
Poll a stale entry.- Overrides:
poll
in classReferenceQueue
- Returns:
- A weak entry or null (if none is stale).
-
toString
Get the string representation.
-