Code cleanup
This commit is contained in:
parent
242897719b
commit
9037b525bd
|
@ -2,6 +2,7 @@ package ctbrec.event;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -11,10 +12,18 @@ import com.google.common.eventbus.AsyncEventBus;
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
|
|
||||||
public class EventBusHolder {
|
public class EventBusHolder {
|
||||||
private static final transient Logger LOG = LoggerFactory.getLogger(EventBusHolder.class);
|
private static final Logger LOG = LoggerFactory.getLogger(EventBusHolder.class);
|
||||||
private static Map<String, EventHandler> handlers = new HashMap<>();
|
private static Map<String, EventHandler> handlers = new HashMap<>();
|
||||||
|
|
||||||
public static final EventBus BUS = new AsyncEventBus(Executors.newFixedThreadPool(10));
|
private EventBusHolder() {}
|
||||||
|
|
||||||
|
public static final EventBus BUS = new AsyncEventBus(Executors.newFixedThreadPool(10, r -> {
|
||||||
|
Thread t = new Thread(r);
|
||||||
|
t.setName("EventBus-" + UUID.randomUUID().toString().substring(0, 8));
|
||||||
|
t.setPriority(Thread.NORM_PRIORITY - 1);
|
||||||
|
return t;
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
public static void register(EventHandler handler) {
|
public static void register(EventHandler handler) {
|
||||||
if(handlers.containsKey(handler.getId())) {
|
if(handlers.containsKey(handler.getId())) {
|
||||||
|
|
Loading…
Reference in New Issue