Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.activemq.message.util
Class MemoryBoundedQueue

    java.lang.Object
      org.codehaus.activemq.message.util.MemoryBoundedQueue

All Implemented Interfaces:
  BoundedPacketQueue

public class MemoryBoundedQueue
extends Object
implements BoundedPacketQueue

MemoryBoundedQueue is a queue bounded by memory usage for Packets

Version:
  $Revision: 1.6 $

Constructor Summary
`(package private)` | `MemoryBoundedQueue(String name, MemoryBoundedQueueManager manager)` Constructor

Method Summary
`void` | `clear()` remove any Packets in the queue
`void` | `close()` close and remove this queue from the MemoryBoundedQueueManager
`Packet` | `dequeue()`
`Packet` | `dequeue(long timeInMillis)` Dequeues a Packet from the head of the queue
`Packet` | `dequeueNoWait()` dequeues a Packet from the head of the queue
`void` | `enqueue(Packet packet)` Enqueue a Packet to this queue
`void` | `enqueueFirst(Packet packet)` Enqueue a Packet to the head of the queue
`void` | `enqueueFirstNoBlock(Packet packet)` Enqueue a packet to the head of the queue with total disregard for memory constraints
`void` | `enqueueNoBlock(Packet packet)` Enqueue a Packet without checking memory usage limits
`Packet` | `get(int index)` retrieve a Packet at an indexed position in the queue
`List` | `getContents()` Retrieve a shallow copy of the contents as a list
`long` | `getLocalMemoryUsedByThisQueue()`
`String` | `getName()`
`boolean` | `isEmpty()`
`boolean` | `isStarted()`
`boolean` | `remove(Packet packet)` Remove a packet from the queue
`Packet` | `remove(String id)` Remove a Packet by it's id
`int` | `size()`
`void` | `start()` enable dequeueing
`void` | `stop()` disable dequeueing
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### MemoryBoundedQueue

    MemoryBoundedQueue(String name,
                       MemoryBoundedQueueManager manager)

  Constructor

Parameters:
  `name` -
  `manager` -

Method Detail

### getName

    public String getName()

  Specified by:
    `getName` in interface `BoundedPacketQueue`
  Returns:
    the name of this MemoryBoundedQueue

### toString

    public String toString()

  Returns:
    a pretty print of this queue

### size

    public int size()

  Specified by:
    `size` in interface `BoundedPacketQueue`
  Returns:
    the number of items held by this queue

### getLocalMemoryUsedByThisQueue

    public long getLocalMemoryUsedByThisQueue()

  Returns:
    an aproximation the memory used by this queue

### close

    public void close()

  close and remove this queue from the MemoryBoundedQueueManager

  Specified by:
    `close` in interface `BoundedPacketQueue`

### enqueueNoBlock

    public void enqueueNoBlock(Packet packet)

  Enqueue a Packet without checking memory usage limits

  Specified by:
    `enqueueNoBlock` in interface `BoundedPacketQueue`
  Parameters:
    `packet` -

### enqueue

    public void enqueue(Packet packet)

  Enqueue a Packet to this queue

  Specified by:
    `enqueue` in interface `BoundedPacketQueue`
  Parameters:
    `packet` -

### enqueueFirstNoBlock

    public final void enqueueFirstNoBlock(Packet packet)

  Enqueue a packet to the head of the queue with total disregard for memory constraints

  Parameters:
    `packet` -

### enqueueFirst

    public void enqueueFirst(Packet packet)
                      throws InterruptedException

  Enqueue a Packet to the head of the queue

  Parameters:
    `packet` -
  Throws:
    `InterruptedException`

### dequeue

    public Packet dequeue()
                   throws InterruptedException

  Specified by:
    `dequeue` in interface `BoundedPacketQueue`
  Returns:
    the first dequeued Packet or blocks until one is available
  Throws:
    `InterruptedException`

### dequeue

    public Packet dequeue(long timeInMillis)
                   throws InterruptedException

  Dequeues a Packet from the head of the queue

  Specified by:
    `dequeue` in interface `BoundedPacketQueue`
  Parameters:
    `timeInMillis` - time to wait for a Packet to be available
  Returns:
    the first Packet or null if none available within timeInMillis
  Throws:
    `InterruptedException`

### dequeueNoWait

    public Packet dequeueNoWait()
                         throws InterruptedException

  dequeues a Packet from the head of the queue

  Specified by:
    `dequeueNoWait` in interface `BoundedPacketQueue`
  Returns:
    the Packet at the head of the queue or null, if none is available
  Throws:
    `InterruptedException`

### isStarted

    public boolean isStarted()

  Specified by:
    `isStarted` in interface `BoundedPacketQueue`
  Returns:
    true if the queue is enabled for dequeing (default = true)

### stop

    public void stop()

  disable dequeueing

  Specified by:
    `stop` in interface `BoundedPacketQueue`

### start

    public void start()

  enable dequeueing

  Specified by:
    `start` in interface `BoundedPacketQueue`

### remove

    public boolean remove(Packet packet)

  Remove a packet from the queue

  Parameters:
    `packet` -
  Returns:
    true if the packet was found

### remove

    public Packet remove(String id)

  Remove a Packet by it's id

  Parameters:
    `id` -
  Returns:

### clear

    public void clear()

  remove any Packets in the queue

  Specified by:
    `clear` in interface `BoundedPacketQueue`

### isEmpty

    public boolean isEmpty()

  Specified by:
    `isEmpty` in interface `BoundedPacketQueue`
  Returns:
    true if the queue is empty

### get

    public Packet get(int index)

  retrieve a Packet at an indexed position in the queue

  Parameters:
    `index` -
  Returns:

### getContents

    public List getContents()

  Retrieve a shallow copy of the contents as a list

  Specified by:
    `getContents` in interface `BoundedPacketQueue`
  Returns:
    a list containing the bounded queue contents

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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