use of com.tvd12.ezyfoxserver.constant.EzyEventType in project ezyfox-server by youngmonkeys.
the class EzyEventControllersImplTest method multiThreadTest.
@SuppressWarnings("unchecked")
@Test
public void multiThreadTest() {
EzyEventControllersImpl sut = new EzyEventControllersImpl();
ExecutorService executorService = Executors.newFixedThreadPool(12);
AtomicBoolean active = new AtomicBoolean(true);
executorService.execute(() -> {
while (active.get()) {
for (EzyEventType eventType : EzyEventType.values()) {
sut.addController(eventType, mock(EzyEventController.class));
}
EzyThreads.sleep(1);
}
});
executorService.execute(() -> {
while (active.get()) {
for (EzyEventType eventType : EzyEventType.values()) {
for (EzyEventController controller : sut.getControllers(eventType)) {
controller.handle(null, null);
}
}
EzyThreads.sleep(1);
}
});
EzyThreads.sleep(1000);
executorService.shutdown();
}
use of com.tvd12.ezyfoxserver.constant.EzyEventType in project ezyfox-server-android-client by youngmonkeys.
the class EzyEventHandlers method handle.
public void handle(EzyEvent event) {
EzyEventType eventType = event.getType();
EzyEventHandler handler = handlers.get(eventType);
if (handler != null)
handler.handle(event);
else
EzyLogger.warn("has no handler for event type: " + eventType);
}
Aggregations