org.activemq.io.util
Class MemoryBoundedPrioritizedQueue

java.lang.Object
  extended by org.activemq.io.util.MemoryBoundedQueue
      extended by org.activemq.io.util.MemoryBoundedPrioritizedQueue
All Implemented Interfaces:
MemoryBoundedObject

public class MemoryBoundedPrioritizedQueue
extends MemoryBoundedQueue

Version:
$Revision: 1.1.1.1 $
Author:
Ramzi Saba A prioritized version of the MemoryBoundedQueue supporting the 10 JMS priority levels 0-9, 0 being the lowest and 9 being the highest.

Field Summary
 
Fields inherited from class org.activemq.io.util.MemoryBoundedQueue
closed, inLock, outLock, stopped, WAIT_TIMEOUT
 
Constructor Summary
MemoryBoundedPrioritizedQueue(MemoryBoundedQueueManager manager, String name)
          Constructor
 
Method Summary
 void clear()
          remove any MemoryManageables in the queue
 MemoryManageable dequeue()
           
 MemoryManageable dequeueNoWait()
          dequeues a MemoryManageable from the head of the queue
 void enqueueAllFirstNoBlock(List packets)
          Enqueue an array of packets to the head of the queue with total disregard for memory constraints
 void enqueueFirstNoBlock(MemoryManageable packet)
          Enqueue a packet to the head of the queue with total disregard for memory constraints
 void enqueueNoBlock(MemoryManageable packet)
          Enqueue a MemoryManageable without checking memory usage limits
 MemoryManageable get(int index)
          retrieve a MemoryManageable at an indexed position in the queue
 List getContents()
          Retrieve a shallow copy of the contents as a list
 boolean isEmpty()
           
 boolean remove(MemoryManageable packet)
          Remove a packet from the queue
 MemoryManageable remove(Object id)
          Remove a MemoryManageable by it's id
 int size()
           
 
Methods inherited from class org.activemq.io.util.MemoryBoundedQueue
close, decrementMemoryUsed, dequeue, enqueue, enqueueFirst, getLocalMemoryUsedByThisQueue, getName, incrementMemoryUsed, isStarted, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemoryBoundedPrioritizedQueue

public MemoryBoundedPrioritizedQueue(MemoryBoundedQueueManager manager,
                                     String name)
Constructor

Parameters:
name -
manager -
name -
Method Detail

size

public int size()
Overrides:
size in class MemoryBoundedQueue
Returns:
the number of items held by this queue

enqueueNoBlock

public void enqueueNoBlock(MemoryManageable packet)
Enqueue a MemoryManageable without checking memory usage limits

Overrides:
enqueueNoBlock in class MemoryBoundedQueue
Parameters:
packet -

enqueueFirstNoBlock

public final void enqueueFirstNoBlock(MemoryManageable packet)
Enqueue a packet to the head of the queue with total disregard for memory constraints

Overrides:
enqueueFirstNoBlock in class MemoryBoundedQueue
Parameters:
packet -

enqueueAllFirstNoBlock

public void enqueueAllFirstNoBlock(List packets)
Enqueue an array of packets to the head of the queue with total disregard for memory constraints

Overrides:
enqueueAllFirstNoBlock in class MemoryBoundedQueue
Parameters:
packets -

dequeue

public MemoryManageable dequeue()
                         throws InterruptedException
Overrides:
dequeue in class MemoryBoundedQueue
Returns:
the first dequeued MemoryManageable or blocks until one is available
Throws:
InterruptedException

dequeueNoWait

public MemoryManageable dequeueNoWait()
                               throws InterruptedException
dequeues a MemoryManageable from the head of the queue

Overrides:
dequeueNoWait in class MemoryBoundedQueue
Returns:
the MemoryManageable at the head of the queue or null, if none is available
Throws:
InterruptedException

remove

public boolean remove(MemoryManageable packet)
Remove a packet from the queue

Overrides:
remove in class MemoryBoundedQueue
Parameters:
packet -
Returns:
true if the packet was found

remove

public MemoryManageable remove(Object id)
Remove a MemoryManageable by it's id

Overrides:
remove in class MemoryBoundedQueue
Parameters:
id -
Returns:

clear

public void clear()
remove any MemoryManageables in the queue

Overrides:
clear in class MemoryBoundedQueue

isEmpty

public boolean isEmpty()
Overrides:
isEmpty in class MemoryBoundedQueue
Returns:
true if the queue is empty

get

public MemoryManageable get(int index)
retrieve a MemoryManageable at an indexed position in the queue

Overrides:
get in class MemoryBoundedQueue
Parameters:
index -
Returns:

getContents

public List getContents()
Retrieve a shallow copy of the contents as a list

Overrides:
getContents in class MemoryBoundedQueue
Returns:
a list containing the bounded queue contents


Copyright © 2004-2010 Protique, Ltd.. All Rights Reserved.