fiftyone.mobile.detection.entities.stream
Class Pool
java.lang.Object
fiftyone.mobile.detection.entities.stream.Pool
- All Implemented Interfaces:
- Disposable
public class Pool
- extends Object
- implements Disposable
As multiple threads need to read from the Source concurrently this class
provides a mechanism for readers to be recycled across threads and requests.
Used by the BaseList to provide multiple readers for the list. The
DetectorDataSet must be disposed of to ensure the readers in the pool are
closed.
|
Constructor Summary |
Pool(Source source)
Constructs a new pool of readers for the source provided. |
|
Method Summary |
void |
dispose()
|
(package private) BinaryReader |
getReader()
Returns a reader to the temp file for exclusive use. |
(package private) void |
release(BinaryReader reader)
Returns the reader to the pool to be used by another process later. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
readers
private final Queue<BinaryReader> readers
source
private final Source source
Pool
Pool(Source source)
- Constructs a new pool of readers for the source provided.
- Parameters:
source - The data source for the list
getReader
BinaryReader getReader()
throws IOException
- Returns a reader to the temp file for exclusive use. Release method must
be called to return the reader to the pool when finished.
- Returns:
- Reader open and ready to read from the temp file
- Throws:
IOException
release
void release(BinaryReader reader)
- Returns the reader to the pool to be used by another process later.
- Parameters:
reader - Reader open and ready to read from the temp file
dispose
public void dispose()
- Specified by:
dispose in interface Disposable