fiftyone.mobile.detection.entities.stream
Class TriePool
java.lang.Object
fiftyone.mobile.detection.entities.stream.TriePool
- All Implemented Interfaces:
- Disposable
public class TriePool
- 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 |
TriePool(TrieSource source)
Constructs a new pool of readers for the source provided. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
readers
private final Queue<TrieReader> readers
source
private final TrieSource source
TriePool
public TriePool(TrieSource source)
- Constructs a new pool of readers for the source provided.
- Parameters:
source - The data source for the list
getReader
public TrieReader 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
public void release(TrieReader 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