# Class QueueTableSequence

java.lang.Object
uk.ac.starlink.table.QueueTableSequence

All Implemented Interfaces:
  `TableSequence`

public class QueueTableSequence extends Object implements TableSequence
TableSequence implementation for concurrent use. Table load successes or failures may be added on one thread, and the sequence used from another. The `nextTable` method will block until a result is available.

Since:
  27 Sep 2010
Author:
  Mark Taylor

## Constructor Summary

Constructors
Constructor
Description
`QueueTableSequence()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`addError(Throwable error)`
Adds a load error to the queue.
`void`
`addTable(StarTable table)`
Adds a table to the queue.
`void`
`endSequence()`
Indicates that no more load success or failure indications will be added by the queue writer.
`StarTable`
`nextTable()`
Returns the next table in the sequence, or null if the end of the sequence is reached.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### QueueTableSequence

public QueueTableSequence()
Constructor.

## Method Details

### addTable

public void addTable(StarTable table)
Adds a table to the queue. This will appear in the TableSequence as a table loadSuccess.

Parameters:
  `table` - successfully loaded table

### addError

public void addError(Throwable error)
Adds a load error to the queue. This will appear in the TableSequence as a table loadFailure.

Parameters:
  `error` - reason for unsuccessful table load attempt

### endSequence

public void endSequence()
Indicates that no more load success or failure indications will be added by the queue writer. Must be called, otherwise the reader will never terminate.

### nextTable

public StarTable nextTable() throws IOException
Description copied from interface: `TableSequence`
Returns the next table in the sequence, or null if the end of the sequence is reached.

Specified by:
  `nextTable` in interface `TableSequence`
Returns:
  next table, or null if there are no more
Throws:
  `IOException` - if there is an error obtaining the table