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:
parent
36c4af35de
commit
972b4c1fe5
@ -44,7 +44,7 @@ public class BungeeScheduler implements TaskScheduler
|
||||
@Override
|
||||
public void cancel(ScheduledTask task)
|
||||
{
|
||||
cancel( task.getId() );
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,7 +34,12 @@ public class BungeeTask implements Runnable, ScheduledTask
|
||||
@Override
|
||||
public void cancel()
|
||||
{
|
||||
running.set( false );
|
||||
boolean wasRunning = running.getAndSet( false );
|
||||
|
||||
if ( wasRunning )
|
||||
{
|
||||
sched.cancel( this.getId() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,11 +81,6 @@ public class BungeeTask implements Runnable, ScheduledTask
|
||||
}
|
||||
}
|
||||
|
||||
// We might have been previously running before, but now we aren't.
|
||||
// If we weren't already cancelled, then cancel ourselves.
|
||||
if ( running.get() )
|
||||
{
|
||||
sched.cancel( this );
|
||||
}
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user