13e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert/* 23e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Copyright (C) 2009 The Android Open Source Project 33e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * 43e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License"); 53e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * you may not use this file except in compliance with the License. 63e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * You may obtain a copy of the License at 73e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * 83e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * http://www.apache.org/licenses/LICENSE-2.0 93e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * 103e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Unless required by applicable law or agreed to in writing, software 113e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * distributed under the License is distributed on an "AS IS" BASIS, 123e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * See the License for the specific language governing permissions and 143e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * limitations under the License. 153e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert */ 163e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 17a48af083ff81555261f334a1e050eae3b02a746cBjorn Bringertpackage com.android.quicksearchbox.util; 183e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 193e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert/** 20a48af083ff81555261f334a1e050eae3b02a746cBjorn Bringert * Runs tasks that have a name tag. 213e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert */ 22a48af083ff81555261f334a1e050eae3b02a746cBjorn Bringertpublic interface NamedTaskExecutor { 233e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 243e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert /** 25a48af083ff81555261f334a1e050eae3b02a746cBjorn Bringert * Schedules a task for execution. Implementations should not throw 26a48af083ff81555261f334a1e050eae3b02a746cBjorn Bringert * {@link java.util.concurrent.RejectedExecutionException} if the task 27a48af083ff81555261f334a1e050eae3b02a746cBjorn Bringert * cannot be run. They should drop it silently instead. 283e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert */ 29a48af083ff81555261f334a1e050eae3b02a746cBjorn Bringert void execute(NamedTask task); 303e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 313e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert /** 32a48af083ff81555261f334a1e050eae3b02a746cBjorn Bringert * Stops any unstarted tasks from running. Implementations of this method must be 33a48af083ff81555261f334a1e050eae3b02a746cBjorn Bringert * idempotent. 343e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert */ 353e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert void cancelPendingTasks(); 363e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 373e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert /** 383e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Shuts down this executor, freeing any resources that it owns. The executor 39a48af083ff81555261f334a1e050eae3b02a746cBjorn Bringert * may not be used after calling this method. Implementations of this method must be 40a48af083ff81555261f334a1e050eae3b02a746cBjorn Bringert * idempotent. 413e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert */ 423e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert void close(); 433e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert 443e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert} 45