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 // Submit all defined preprocessing methods as async tasks
for (int i = 0; i < handlerList.size(); i++) { for (int i = 0; i < handlerList.size(); i++) {
if (handlerList.get(i).getPreprocessMethod() == null) { 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(); 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 // Await for them to complete
@@ -44,16 +47,15 @@ public class AsyncEventLoop extends AdvancedEventLoop {
// data obtained from EventBatch // data obtained from EventBatch
for (int i = 0; i < handlerList.size(); i++) { for (int i = 0; i < handlerList.size(); i++) {
ExecutorLink link = handlerList.get(i); ExecutorLink link = handlerList.get(i);
if (link.isIgnoreCancelled() && event.isCanceled()) if (!link.isIgnoreCancelled() || !event.isCanceled()) {
continue; try {
if (link.getResultInjection() != null)
try { link.getMethod().invoke(link.getObject(), event, eventBatch.getInjectionObject(i));
if (link.getResultInjection() != null) else
link.getMethod().invoke(link.getObject(), event, eventBatch.getInjectionObject(i)); link.getMethod().invoke(link.getObject(), event);
else } catch (IllegalAccessException | InvocationTargetException e) {
link.getMethod().invoke(link.getObject(), event); log.error("Exception caught while attempting to dispatch {}.", eventType.getSimpleName(), e);
} catch (IllegalAccessException | InvocationTargetException e) { }
log.error("Exception caught while attempting to dispatch {}.", eventType.getSimpleName(), e);
} }
} }
} }