Commenting
This commit is contained in:
@@ -19,10 +19,12 @@ public class AsyncEventLoop extends AdvancedEventLoop {
|
||||
Class<? extends Event> eventType = event.getClass();
|
||||
|
||||
if (handlers.containsKey(eventType)) {
|
||||
// Create inter-thread state
|
||||
List<ExecutorLink> handlerList = handlers.get(eventType);
|
||||
EventBatch eventBatch = new EventBatch(handlerList.size());
|
||||
CountDownLatch latch = new CountDownLatch(handlerList.size());
|
||||
|
||||
// Submit all defined preprocessing methods as async tasks
|
||||
for (int i = 0; i < handlerList.size(); i++) {
|
||||
if (handlerList.get(i).getPreprocessMethod() == null) {
|
||||
latch.countDown();
|
||||
@@ -31,12 +33,15 @@ public class AsyncEventLoop extends AdvancedEventLoop {
|
||||
preEventExecutor.submit(new PreprocessTask(i, eventBatch, latch, handlerList.get(i), event));
|
||||
}
|
||||
|
||||
// Await for them to complete
|
||||
try {
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Synchronously invoke EventHandlers with
|
||||
// data obtained from EventBatch
|
||||
for (int i = 0; i < handlerList.size(); i++) {
|
||||
ExecutorLink link = handlerList.get(i);
|
||||
if (link.isIgnoreCancelled() && event.isCanceled())
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package mc.core.events.async;
|
||||
|
||||
/**
|
||||
* Stores state to pass from async executors to sync
|
||||
*
|
||||
* TODO: Change name, misleading
|
||||
*/
|
||||
public class EventBatch {
|
||||
private Object[] returnInject;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user