dk.deepthought.sidious.util
Class SidiousQueue<T>

java.lang.Object
  extended by dk.deepthought.sidious.util.SidiousQueue<T>
Direct Known Subclasses:
GoalHandlerEngine

@ThreadSafe
public abstract class SidiousQueue<T>
extends java.lang.Object

Abstract representation of a queue which uses a thread to dequeue and process elements.

Implements a work queue; which allows for asynchronous processing of enqueued items.

Author:
Deepthought

Nested Class Summary
private  class SidiousQueue.InternalThread
          Private thread implementation.
 
Field Summary
private  boolean interrupted
          Boolean to indicate whether the thread has been interrupted.
private static org.apache.commons.logging.Log logger
          Logger for this class
private  java.util.List<T> queue
          Internal queue.
 
Constructor Summary
protected SidiousQueue(java.lang.String name)
          Constructor that starts a new thread.
 
Method Summary
 void enqueue(T item)
          Enqueues an item.
 void interrupt()
          Interrupts the thread.
protected abstract  void process(T item)
          The processing of an item.
private  void startThread(java.lang.String name)
          Method to start the thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final org.apache.commons.logging.Log logger
Logger for this class


interrupted

private boolean interrupted
Boolean to indicate whether the thread has been interrupted.


queue

private final java.util.List<T> queue
Internal queue.

Constructor Detail

SidiousQueue

protected SidiousQueue(java.lang.String name)
Constructor that starts a new thread.

Method Detail

enqueue

public final void enqueue(T item)
Enqueues an item.

Parameters:
item - the item to be enqueued

interrupt

public final void interrupt()
Interrupts the thread.


process

protected abstract void process(T item)
The processing of an item.

Parameters:
item - the item to be processed.

startThread

private void startThread(java.lang.String name)
Method to start the thread.

Parameters:
name - the name of the thread


Copyright © Deepthought Development - All Rights Reserved.