Further fix task clean up issues by moving the BungeeScheduler's cancel(ScheduledTask) method to just call the cancel() method on the task. The cancel call was moved to BungeeTask's cancel method.

This patch makes the patch transparent to existing callers using cancel(ScheduledTask) from the scheduler. It also simplifies some logic in BungeeTask itself.
This commit is contained in:
Tux 2014-12-14 00:02:29 -05:00 committed by md_5
parent 36c4af35de
commit 972b4c1fe5
2 changed files with 8 additions and 8 deletions

View File

@ -44,7 +44,7 @@ public class BungeeScheduler implements TaskScheduler
@Override @Override
public void cancel(ScheduledTask task) public void cancel(ScheduledTask task)
{ {
cancel( task.getId() ); task.cancel();
} }
@Override @Override

View File

@ -34,7 +34,12 @@ public class BungeeTask implements Runnable, ScheduledTask
@Override @Override
public void cancel() public void cancel()
{ {
running.set( false ); boolean wasRunning = running.getAndSet( false );
if ( wasRunning )
{
sched.cancel( this.getId() );
}
} }
@Override @Override
@ -76,11 +81,6 @@ public class BungeeTask implements Runnable, ScheduledTask
} }
} }
// We might have been previously running before, but now we aren't. cancel();
// If we weren't already cancelled, then cancel ourselves.
if ( running.get() )
{
sched.cancel( this );
}
} }
} }