ref[event]: rename

This commit is contained in:
godotg
2024-04-10 19:38:26 +08:00
parent 966fe14d89
commit 76c20ff026
5 changed files with 7 additions and 7 deletions
@@ -114,7 +114,7 @@ public abstract class EventBus {
for (var receiver : receivers) {
switch (receiver.bus()) {
case CurrentThread -> doReceiver(receiver, event);
case AsyncThread -> execute(event.executorHash(), () -> doReceiver(receiver, event));
case AsyncThread -> asyncExecute(event.executorHash(), () -> doReceiver(receiver, event));
// case VirtualThread -> Thread.ofVirtual().name("virtual-on" + clazz.getSimpleName()).start(() -> doReceiver(receiver, event));
}
}
@@ -132,13 +132,13 @@ public abstract class EventBus {
}
public static void asyncExecute(Runnable runnable) {
execute(RandomUtils.randomInt(), runnable);
asyncExecute(RandomUtils.randomInt(), runnable);
}
/**
* Use the event thread specified by the hashcode to execute the task
*/
public static void execute(int executorHash, Runnable runnable) {
public static void asyncExecute(int executorHash, Runnable runnable) {
executors[Math.abs(executorHash % EXECUTORS_SIZE)].execute(ThreadUtils.safeRunnable(runnable));
}
@@ -45,7 +45,7 @@ public class SignalBridgeTest {
var countDownLatch = new CountDownLatch(executorSize);
for (var i = 0; i < executorSize; i++) {
EventBus.execute(i, new Runnable() {
EventBus.asyncExecute(i, new Runnable() {
@Override
public void run() {
addAndRemoveArray();
+1 -1
View File
@@ -69,7 +69,7 @@ public class EntityCache<PK extends Comparable<PK>, E extends IEntity<PK>> imple
var entity = pnode.getEntity();
@SuppressWarnings("unchecked")
var entityClass = (Class<E>) entityDef.getClazz();
EventBus.execute(entityClass.hashCode(), new Runnable() {
EventBus.asyncExecute(entityClass.hashCode(), new Runnable() {
@Override
public void run() {
var collection = OrmContext.getOrmManager().getCollection(entityClass);
@@ -75,7 +75,7 @@ public class CronOrmPersister extends AbstractOrmPersister {
if (!OrmContext.isStop()) {
SchedulerBus.schedule(() -> {
if (!OrmContext.isStop()) {
EventBus.execute(entityDef.getClazz().hashCode(), () -> {
EventBus.asyncExecute(entityDef.getClazz().hashCode(), () -> {
entityCaches.persistAll();
schedulePersist();
});
@@ -44,7 +44,7 @@ public class TimeOrmPersister extends AbstractOrmPersister {
public void start() {
SchedulerBus.scheduleAtFixedRate(() -> {
if (!OrmContext.isStop()) {
EventBus.execute(entityDef.getClazz().hashCode(), () -> entityCaches.persistAll());
EventBus.asyncExecute(entityDef.getClazz().hashCode(), () -> entityCaches.persistAll());
}
}, rate, TimeUnit.MILLISECONDS);
}