public class FileCacheFaceQueue extends AbstractFaceQueue
FaceQueue
loading faces from ImageCache
instances.Modifier and Type | Class and Description |
---|---|
private class |
FileCacheFaceQueue.LoadTask
A thread which loads one face from the caches.
|
private class |
FileCacheFaceQueue.SaveTask
A thread which saves one face to the caches.
|
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.ExecutorService |
executorService
The
ExecutorService used to execute face loading. |
private int |
id
Counts the number of calls to
reset() . |
private ImageCache |
imageCacheMagicMap
The image cache used for loading magic map images.
|
private ImageCache |
imageCacheOriginal
The image cache used for loading original images.
|
private ImageCache |
imageCacheScaled
The image cache used for loading scaled images.
|
private java.util.Collection<Face> |
pendingLoadFaces
The faces for which
loadFace(Face) has been called but that are
not yet processed. |
private java.lang.Object |
sync
The object used for synchronization.
|
Constructor and Description |
---|
FileCacheFaceQueue(ImageCache imageCacheOriginal,
ImageCache imageCacheScaled,
ImageCache imageCacheMagicMap)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
loadFace(Face face)
Request a face.
|
void |
reset()
Reset the processing: forget about pending faces.
|
void |
saveFace(Face face,
FaceImages faceImages)
Saves a face to the caches.
|
addFaceQueueListener, fireFaceFailed, fireFaceLoaded, removeFaceQueueListener
@NotNull private final java.util.concurrent.ExecutorService executorService
ExecutorService
used to execute face loading. The pool
consists of one thread; this means all requests are serialized.private int id
reset()
. An ExecutorService
does not allow to cancel scheduled but still pending
requests. Therefore the thread checks if this ID matches the ID value at
creation time. If the IDs do not match it exits.@NotNull private final ImageCache imageCacheMagicMap
@NotNull private final ImageCache imageCacheOriginal
@NotNull private final ImageCache imageCacheScaled
@NotNull private final java.util.Collection<Face> pendingLoadFaces
loadFace(Face)
has been called but that are
not yet processed.@NotNull private final java.lang.Object sync
public FileCacheFaceQueue(@NotNull ImageCache imageCacheOriginal, @NotNull ImageCache imageCacheScaled, @NotNull ImageCache imageCacheMagicMap)
imageCacheOriginal
- the image cache used for loading original image
filesimageCacheScaled
- the image cache used for loading scaled image
filesimageCacheMagicMap
- the image cache used for loading magic map
image filespublic void loadFace(@NotNull Face face)
FaceQueueListener.faceLoaded(Face, FaceImages)
or FaceQueueListener.faceFailed(Face)
for the face. Faces re-requested
while still processing may be notified only once.face
- the requested facepublic void reset()
public void saveFace(@NotNull Face face, @NotNull FaceImages faceImages)
face
- the face to writefaceImages
- the image information to write