Package org.apache.sysds.runtime.ooc.cache.io

# Class CloseableQueue<T>

java.lang.Object
org.apache.sysds.runtime.ooc.cache.io.CloseableQueue<T>

public class CloseableQueue<T> extends Object

## Constructor Summary

Constructors
Constructor
Description
`CloseableQueue()`

## Method Summary

Modifier and Type
Method
Description
`boolean`
`close()`
Close queue for N consumers.
`boolean`
`enqueueIfOpen(T task)`
Enqueue if the queue is not closed.
`boolean`
`isFinished()`
`T`
`poll(long timeout, TimeUnit unit)`
Poll with max timeout.
`T`
`take()`

### Methods inherited from class java.lang.Object

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

## Constructor Details

### CloseableQueue

public CloseableQueue()

## Method Details

### enqueueIfOpen

public boolean enqueueIfOpen(T task) throws InterruptedException
Enqueue if the queue is not closed.

Returns:
  false if already closed
Throws:
  `InterruptedException`

### take

public T take() throws InterruptedException

Throws:
  `InterruptedException`

### poll

public T poll(long timeout, TimeUnit unit) throws InterruptedException
Poll with max timeout.

Returns:
  item, or null if: - timeout, or - queue has been closed and this consumer reached its poison pill
Throws:
  `InterruptedException`

### close

public boolean close() throws InterruptedException
Close queue for N consumers. Each consumer will receive exactly one poison pill and then should stop.

Throws:
  `InterruptedException`

### isFinished

public boolean isFinished()