Archived
0

Some more commenting for AsyncEventLoop

This commit is contained in:
Daniil
2018-07-26 11:23:11 +07:00
parent abae528d0b
commit 8c6c6bde6c

View File

@@ -27,10 +27,13 @@ public class AsyncEventLoop extends AdvancedEventLoop {
// Submit all defined preprocessing methods as async tasks
for (int i = 0; i < handlerList.size(); i++) {
if (handlerList.get(i).getPreprocessMethod() == null) {
// We have already "allocated" a space for this task in CountDownLatch,
// but since there is no actual preprocess method defined for this handler
// we just skip it by ticking the latch down manually
latch.countDown();
continue;
} else {
preEventExecutor.submit(new PreprocessTask(i, eventBatch, latch, handlerList.get(i), event));
}
preEventExecutor.submit(new PreprocessTask(i, eventBatch, latch, handlerList.get(i), event));
}
// Await for them to complete
@@ -44,16 +47,15 @@ public class AsyncEventLoop extends AdvancedEventLoop {
// data obtained from EventBatch
for (int i = 0; i < handlerList.size(); i++) {
ExecutorLink link = handlerList.get(i);
if (link.isIgnoreCancelled() && event.isCanceled())
continue;
try {
if (link.getResultInjection() != null)
link.getMethod().invoke(link.getObject(), event, eventBatch.getInjectionObject(i));
else
link.getMethod().invoke(link.getObject(), event);
} catch (IllegalAccessException | InvocationTargetException e) {
log.error("Exception caught while attempting to dispatch {}.", eventType.getSimpleName(), e);
if (!link.isIgnoreCancelled() || !event.isCanceled()) {
try {
if (link.getResultInjection() != null)
link.getMethod().invoke(link.getObject(), event, eventBatch.getInjectionObject(i));
else
link.getMethod().invoke(link.getObject(), event);
} catch (IllegalAccessException | InvocationTargetException e) {
log.error("Exception caught while attempting to dispatch {}.", eventType.getSimpleName(), e);
}
}
}
}