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