001/** 002 * Copyright (c) 2008-2009 Apple Inc. All rights reserved. 003 * Copyright (C) 2012 FuseSource, Inc. 004 * http://fusesource.com 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019package org.fusesource.hawtdispatch; 020 021/** 022 * <p> 023 * Implemented by dispatch objects that can be configured with a target queue 024 * that it uses for executing the object's asynchronous tasks. 025 * </p> 026 * 027 * @author <a href="http://hiramchirino.com">Hiram Chirino</a> 028 */ 029public interface DispatchObject extends Suspendable { 030 031 /** 032 * <p> 033 * Sets the target queue for this object. 034 * </p><p> 035 * An object's target queue is responsible for processing the object. 036 * </p><p> 037 * A dispatch queue's priority is inherited by its target queue. Use the 038 * {@link Dispatch#getGlobalQueue()} method to obtain suitable target queue 039 * of the desired priority. 040 * </p><p> 041 * A dispatch source's target queue specifies where its event handler and 042 * cancellation handler runnables will be submitted. 043 * </p> 044 * 045 * @param queue 046 * The new target queue for the object. The queue is retained, and the 047 * previous one, if any, is released. 048 * The result of passing NULL in this parameter is undefined. 049 */ 050 public void setTargetQueue(DispatchQueue queue); 051 052 /** 053 * <p> 054 * Gets the target queue for this object. 055 * </p> 056 * 057 * @see #setTargetQueue(DispatchQueue) 058 * @return the target queue of this object. 059 */ 060 public DispatchQueue getTargetQueue(); 061 062}