/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.camera2.utils;
import android.hardware.camera2.utils.TaskDrainer.DrainListener;
import android.os.Handler;
/**
* Keep track of a single concurrent task starting and finishing;
* allow draining the existing task and figuring out when the task has finished
* (and won't restart).
*
*
The initial state is to allow all tasks to be started and finished. A task may only be started
* once, after which it must be finished before starting again. Likewise, finishing a task
* that hasn't been started is also not allowed.
*
*
When draining begins, the task cannot be started again. This guarantees that at some
* point the task will be finished forever, at which point the {@link DrainListener#onDrained}
* callback will be invoked.
*/
public class TaskSingleDrainer {
private final TaskDrainer