001/* 002 * Trident - A Multithreaded Server Alternative 003 * Copyright 2014 The TridentSDK Team 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package net.tridentsdk.concurrent; 019 020import net.tridentsdk.plugin.Plugin; 021 022/** 023 * The internal representation of a scheduled task, implemented inside the scheduler to manage the wrapping for {@link 024 * ScheduledRunnable} 025 * 026 * @author The TridentSDK Team 027 * @since 0.3-alpha-DP 028 */ 029public interface ScheduledTask extends Runnable { 030 /** 031 * Gets the interval set or created by the task 032 * 033 * @return the interval, as defined in {@link ScheduledTask#setInterval(long)} 034 */ 035 long interval(); 036 037 /** 038 * Interval is the ticks left of a specific action for repeating and delayed tasks 039 * 040 * <p>For delayed tasks, the interval is the amount of ticks delay, and for repeating, interval is the amount of 041 * ticks between each repeat of the task.</p> 042 * 043 * <p>Setting the interval will become effective the next tick</p> 044 * 045 * @param interval the interval to set the task to 046 */ 047 void setInterval(long interval); 048 049 /** 050 * The task scheduling type 051 * 052 * @return the type the task is scheduled according to 053 */ 054 TaskType type(); 055 056 /** 057 * The execution runnable, invoked when the task is scheduled to occur 058 * 059 * @return the runnable that is run at scheduled time 060 */ 061 ScheduledRunnable runnable(); 062 063 /** 064 * The plugin that scheduled the task, or passed in when scheduled 065 * 066 * @return the scheduling plugin 067 */ 068 Plugin owner(); 069 070 /** 071 * Cancels the task, only needed for repeating tasks. Scheduled later and run tasks are auto cancelled. 072 */ 073 void cancel(); 074}