mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 22:47:49 +01:00
Merge Task#scheduleForShutdown
into Task#schedule
This commit is contained in:
parent
1c92414cad
commit
75964f87b4
@ -100,25 +100,25 @@ public class Task implements Runnable {
|
|||||||
* Sets up the task for correct execution.
|
* Sets up the task for correct execution.
|
||||||
*/
|
*/
|
||||||
public void schedule() {
|
public void schedule() {
|
||||||
Int2ObjectMap<Task> tasks = this.schedulerManager.tasks;
|
if(this.shutdown) {
|
||||||
synchronized (tasks) {
|
Int2ObjectMap<Task> shutdownTasks = this.schedulerManager.shutdownTasks;
|
||||||
tasks.put(getId(), this);
|
synchronized (shutdownTasks) {
|
||||||
}
|
shutdownTasks.put(getId(), this);
|
||||||
if(owningExtension != null) {
|
}
|
||||||
this.schedulerManager.onScheduleFromExtension(owningExtension, this);
|
if (owningExtension != null) {
|
||||||
}
|
this.schedulerManager.onScheduleShutdownFromExtension(owningExtension, this);
|
||||||
this.future = this.repeat == 0L ?
|
}
|
||||||
this.schedulerManager.getTimerExecutionService().schedule(this, this.delay, TimeUnit.MILLISECONDS) :
|
} else {
|
||||||
this.schedulerManager.getTimerExecutionService().scheduleAtFixedRate(this, this.delay, this.repeat, TimeUnit.MILLISECONDS);
|
Int2ObjectMap<Task> tasks = this.schedulerManager.tasks;
|
||||||
}
|
synchronized (tasks) {
|
||||||
|
tasks.put(getId(), this);
|
||||||
public void scheduleForShutdown() {
|
}
|
||||||
Int2ObjectMap<Task> shutdownTasks = this.schedulerManager.shutdownTasks;
|
if (owningExtension != null) {
|
||||||
synchronized (shutdownTasks) {
|
this.schedulerManager.onScheduleFromExtension(owningExtension, this);
|
||||||
shutdownTasks.put(getId(), this);
|
}
|
||||||
}
|
this.future = this.repeat == 0L ?
|
||||||
if (owningExtension != null) {
|
this.schedulerManager.getTimerExecutionService().schedule(this, this.delay, TimeUnit.MILLISECONDS) :
|
||||||
this.schedulerManager.onScheduleShutdownFromExtension(owningExtension, this);
|
this.schedulerManager.getTimerExecutionService().scheduleAtFixedRate(this, this.delay, this.repeat, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,11 +162,7 @@ public class TaskBuilder {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public Task schedule() {
|
public Task schedule() {
|
||||||
Task task = build();
|
Task task = build();
|
||||||
if (this.shutdown) {
|
task.schedule();
|
||||||
task.scheduleForShutdown();
|
|
||||||
} else {
|
|
||||||
task.schedule();
|
|
||||||
}
|
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user