Completed some TODOs
This commit is contained in:
@@ -38,18 +38,16 @@ public class EventPipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RegisteredEventHandler handler = handlers.get(currentIndex);
|
RegisteredEventHandler handler = handlers.get(currentIndex);
|
||||||
|
if (!event.isCanceled() || !handler.isIgnoreCancelled()) {
|
||||||
service.addTask(new ResourceRunnable() {
|
service.addTask(new ResourceRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// TODO: Do we really need to process this in an async thread?
|
|
||||||
if (!event.isCanceled() || !handler.isIgnoreCancelled()) {
|
|
||||||
try {
|
try {
|
||||||
handler.getMethod().invoke(handler.getObject(), event);
|
handler.getMethod().invoke(handler.getObject(), event);
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
log.error("Unable to dispatch event " + event.getClass().getSimpleName() + " to handler " + event.getClass().getName(), e);
|
log.error("Unable to dispatch event " + event.getClass().getSimpleName() + " to handler " + event.getClass().getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void after() {
|
public void after() {
|
||||||
@@ -57,6 +55,10 @@ public class EventPipeline {
|
|||||||
next(service);
|
next(service);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
currentIndex++;
|
||||||
|
next(service);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PipelineState {
|
public enum PipelineState {
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ public class FullAsyncEventLoop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (queue.peek().getState() == EventPipeline.PipelineState.FINISHED) {
|
if (queue.peek().getState() == EventPipeline.PipelineState.FINISHED) {
|
||||||
// TODO: Post-event callback?
|
|
||||||
queue.poll();
|
queue.poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import java.util.concurrent.ArrayBlockingQueue;
|
|||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
|
||||||
public class EventExecutorService {
|
public class EventExecutorService {
|
||||||
|
private static final boolean WORKER_INSTANT_EXECUTE = false;
|
||||||
private BlockingQueue<ResourceRunnable> queue = new ArrayBlockingQueue<>(100);
|
private BlockingQueue<ResourceRunnable> queue = new ArrayBlockingQueue<>(100);
|
||||||
private ScheduleStrategy strategy = new DefaultScheduleStrategy();
|
private ScheduleStrategy strategy = new DefaultScheduleStrategy();
|
||||||
private Set<Thread> executorThreads = new HashSet<>();
|
private Set<Thread> executorThreads = new HashSet<>();
|
||||||
@@ -42,8 +43,7 @@ public class EventExecutorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addTask(ResourceRunnable task) {
|
public void addTask(ResourceRunnable task) {
|
||||||
if (Thread.currentThread() instanceof ExecutorThread) {
|
if (WORKER_INSTANT_EXECUTE && Thread.currentThread() instanceof ExecutorThread) {
|
||||||
// TODO: Do we really need instant execution?
|
|
||||||
((ExecutorThread) Thread.currentThread()).executeTask(task);
|
((ExecutorThread) Thread.currentThread()).executeTask(task);
|
||||||
} else
|
} else
|
||||||
queue.offer(task);
|
queue.offer(task);
|
||||||
|
|||||||
Reference in New Issue
Block a user