mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-01 17:36:46 +01:00
Clean queuemanager on disable
This commit is contained in:
parent
17c64251db
commit
7c9d09a878
@ -2,7 +2,6 @@ package com.gmail.nossr50.database.queuemanager;
|
|||||||
|
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
|
|
||||||
public class AsyncQueueManager implements Runnable {
|
public class AsyncQueueManager implements Runnable {
|
||||||
|
|
||||||
private LinkedBlockingQueue<Queueable> queue;
|
private LinkedBlockingQueue<Queueable> queue;
|
||||||
@ -13,6 +12,7 @@ public class AsyncQueueManager implements Runnable {
|
|||||||
this.running = true;
|
this.running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while(running) {
|
while(running) {
|
||||||
@ -24,10 +24,6 @@ public class AsyncQueueManager implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable() {
|
|
||||||
running = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean queue(Queueable task) {
|
public boolean queue(Queueable task) {
|
||||||
return queue.offer(task);
|
return queue.offer(task);
|
||||||
}
|
}
|
||||||
@ -50,4 +46,16 @@ public class AsyncQueueManager implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void disable() {
|
||||||
|
running = false;
|
||||||
|
// Throw one more Queueable into queue to unblock take()
|
||||||
|
queue.add(new EndThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EndThread implements Queueable {
|
||||||
|
@Override
|
||||||
|
public void run() { }
|
||||||
|
@Override
|
||||||
|
public String getPlayer() { return null; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,6 +176,10 @@ public class mcMMO extends JavaPlugin {
|
|||||||
catch (NullPointerException e) {}
|
catch (NullPointerException e) {}
|
||||||
|
|
||||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||||
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
|
queueManager.disable();
|
||||||
|
queueManager = null;
|
||||||
|
}
|
||||||
HandlerList.unregisterAll(this); // Cancel event registrations
|
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||||
|
|
||||||
if (Config.getInstance().getBackupsEnabled()) {
|
if (Config.getInstance().getBackupsEnabled()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user