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    
019    package org.fusesource.hawtdispatch;
020    
021    /**
022     * <p>
023     * Implemented by dispatch objects which can suspend the
024     * execution of dispatch tasks.
025     * </p>
026     */
027    public interface Suspendable {
028    
029        /**
030         * <p>
031         * Suspends the invocation of tasks on a dispatch object.
032         * </p><p>
033         * A suspended object will not invoke any tasks associated with it. The
034         * suspension of an object will occur after any running runnable associated with
035         * the object completes.
036         * </p><p>
037         * Calls to {@link #suspend()} must be balanced with calls
038         * to {@link #resume()}.
039         * </p>
040         *
041         * @see #resume()
042         */
043        public void suspend();
044    
045        /**
046         * <p>
047         * Resumes the invocation of tasks on a dispatch object.
048         * </p>
049         *
050         * @see #suspend()
051         */
052        public void resume();
053    
054        /**
055         * @see #resume()
056         * @see #suspend()
057         * @return true if the the current object is suspended.
058         */
059        public boolean isSuspended();
060        
061    }